[asterisk-commits] elguero: trunk r369110 - in /trunk: ./ include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 19 21:07:04 CDT 2012


Author: elguero
Date: Tue Jun 19 21:07:00 2012
New Revision: 369110

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=369110
Log:
Fix NULL pointer segfault in ast_sockaddr_parse()

While working with ast_parse_arg() to perform a validity check, a segfault
occurred.  The segfault occurred due to passing a NULL pointer to
ast_sockaddr_parse() from ast_parse_arg().  According to the documentation in
config.h, "result pointer to the result.  NULL is valid here, and can be used to
perform only the validity checks."

This patch fixes the segfault by checking for a NULL pointer.  This patch also
adds documentation to netsock2.h about why it is necessary to check for a NULL
pointer.

(Closes issue ASTERISK-20006)
Reported by: Michael L. Young
Tested by: Michael L. Young
Patches:
asterisk-20006-netsock-null-ptr.diff uploaded by Michael L. Young (license 5026)

Review: https://reviewboard.asterisk.org/r/1990/
........

Merged revisions 369108 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 369109 from http://svn.asterisk.org/svn/asterisk/branches/10

Modified:
    trunk/   (props changed)
    trunk/include/asterisk/netsock2.h
    trunk/main/netsock2.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-10-merged' - no diff available.

Modified: trunk/include/asterisk/netsock2.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/netsock2.h?view=diff&rev=369110&r1=369109&r2=369110
==============================================================================
--- trunk/include/asterisk/netsock2.h (original)
+++ trunk/include/asterisk/netsock2.h Tue Jun 19 21:07:00 2012
@@ -343,7 +343,8 @@
  *
  * Host names are NOT allowed.
  *
- * \param[out] addr The resulting ast_sockaddr
+ * \param[out] addr The resulting ast_sockaddr. This MAY be NULL from 
+ * functions that are performing validity checks only, e.g. ast_parse_arg().
  * \param str The string to parse
  * \param flags If set to zero, a port MAY be present. If set to
  * PARSE_PORT_IGNORE, a port MAY be present but will be ignored. If set to

Modified: trunk/main/netsock2.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/netsock2.c?view=diff&rev=369110&r1=369109&r2=369110
==============================================================================
--- trunk/main/netsock2.c (original)
+++ trunk/main/netsock2.c Tue Jun 19 21:07:00 2012
@@ -235,8 +235,10 @@
 			"addresses. Ignoring all but the first.\n");
 	}
 
-	addr->len = res->ai_addrlen;
-	memcpy(&addr->ss, res->ai_addr, addr->len);
+	if (addr) {
+		addr->len = res->ai_addrlen;
+		memcpy(&addr->ss, res->ai_addr, addr->len);
+	}
 
 	freeaddrinfo(res);
 




More information about the asterisk-commits mailing list