[asterisk-commits] elguero: branch 1.8 r369108 - in /branches/1.8: include/asterisk/ main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jun 19 21:03:29 CDT 2012
Author: elguero
Date: Tue Jun 19 21:03:22 2012
New Revision: 369108
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=369108
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/
Modified:
branches/1.8/include/asterisk/netsock2.h
branches/1.8/main/netsock2.c
Modified: branches/1.8/include/asterisk/netsock2.h
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/include/asterisk/netsock2.h?view=diff&rev=369108&r1=369107&r2=369108
==============================================================================
--- branches/1.8/include/asterisk/netsock2.h (original)
+++ branches/1.8/include/asterisk/netsock2.h Tue Jun 19 21:03:22 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: branches/1.8/main/netsock2.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/netsock2.c?view=diff&rev=369108&r1=369107&r2=369108
==============================================================================
--- branches/1.8/main/netsock2.c (original)
+++ branches/1.8/main/netsock2.c Tue Jun 19 21:03:22 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