[asterisk-commits] mmichelson: trunk r218566 - /trunk/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 15 10:40:19 CDT 2009


Author: mmichelson
Date: Tue Sep 15 10:40:14 2009
New Revision: 218566

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=218566
Log:
Use a better method of ensuring null-termination of the buffer
while reading the SDP when using TCP.


Modified:
    trunk/channels/chan_sip.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=218566&r1=218565&r2=218566
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Tue Sep 15 10:40:14 2009
@@ -2962,12 +2962,13 @@
 		/* In order to know how much to read, we need the content-length header */
 		if (sscanf(get_header(&reqcpy, "Content-Length"), "%30d", &cl)) {
 			while (cl > 0) {
+				size_t bytes_read;
 				ast_mutex_lock(&tcptls_session->lock);
-				if (!fread(buf, MIN(sizeof(buf) - 1, cl), 1, tcptls_session->f)) {
+				if (!(bytes_read = fread(buf, MIN(sizeof(buf) - 1, cl), 1, tcptls_session->f))) {
 					ast_mutex_unlock(&tcptls_session->lock);
 					goto cleanup;
 				}
-				buf[sizeof(buf)-1] = '\0';
+				buf[bytes_read] = '\0';
 				ast_mutex_unlock(&tcptls_session->lock);
 				if (me->stop)
 					goto cleanup;




More information about the asterisk-commits mailing list