[asterisk-commits] seanbright: branch 1.6.2 r302548 - /branches/1.6.2/res/res_agi.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 19 12:37:18 CST 2011


Author: seanbright
Date: Wed Jan 19 12:37:09 2011
New Revision: 302548

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=302548
Log:
Properly handle partial reads from fgets() when handling AGIs.

When fgets() failed with EAGAIN, we were continually decrementing the available
space left in our buffer, resulting in botched command handling.

(closes issue #16032)
Reported by: notahat
Patches:
      agi_buffer_patch2.diff uploaded by fnordian (license 110)

Modified:
    branches/1.6.2/res/res_agi.c

Modified: branches/1.6.2/res/res_agi.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/res/res_agi.c?view=diff&rev=302548&r1=302547&r2=302548
==============================================================================
--- branches/1.6.2/res/res_agi.c (original)
+++ branches/1.6.2/res/res_agi.c Wed Jan 19 12:37:09 2011
@@ -2920,7 +2920,7 @@
 			retry = AGI_NANDFS_RETRY;
 			buf[0] = '\0';
 
-			while (buflen < (len - 1)) {
+			while (len > 1) {
 				res = fgets(buf + buflen, len, readf);
 				if (feof(readf))
 					break;
@@ -2931,7 +2931,7 @@
 				buflen = strlen(buf);
 				if (buflen && buf[buflen - 1] == '\n')
 					break;
-				len -= buflen;
+				len = sizeof(buf) - buflen;
 				if (agidebug)
 					ast_verbose( "AGI Rx << temp buffer %s - errno %s\n", buf, strerror(errno));
 			}




More information about the asterisk-commits mailing list