]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 302548 via svnmerge from
authorSean Bright <sean@malleable.com>
Wed, 19 Jan 2011 18:43:11 +0000 (18:43 +0000)
committerSean Bright <sean@malleable.com>
Wed, 19 Jan 2011 18:43:11 +0000 (18:43 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.6.2

........
  r302548 | seanbright | 2011-01-19 13:37:09 -0500 (Wed, 19 Jan 2011) | 10 lines

  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)
........

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@302549 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/res_agi.c

index f7bc8d9cf45a3c6dabb0ce2b6e06112418e1ec01..cd4760b411d573e6b92060f42b6b25d55af0eba5 100644 (file)
@@ -3391,7 +3391,7 @@ static enum agi_result run_agi(struct ast_channel *chan, char *request, AGI *agi
                        retry = AGI_NANDFS_RETRY;
                        buf[0] = '\0';
 
-                       while (buflen < (len - 1)) {
+                       while (len > 1) {
                                res = fgets(buf + buflen, len, readf);
                                if (feof(readf))
                                        break;
@@ -3402,7 +3402,7 @@ static enum agi_result run_agi(struct ast_channel *chan, char *request, AGI *agi
                                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));
                        }