]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 226159 via svnmerge from
authorTilghman Lesher <tilghman@meg.abyt.es>
Tue, 27 Oct 2009 20:23:54 +0000 (20:23 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Tue, 27 Oct 2009 20:23:54 +0000 (20:23 +0000)
https://origsvn.digium.com/svn/asterisk/trunk

................
  r226159 | tilghman | 2009-10-27 15:22:07 -0500 (Tue, 27 Oct 2009) | 14 lines

  Merged revisions 226138 via svnmerge from
  https://origsvn.digium.com/svn/asterisk/branches/1.4

  ........
    r226138 | tilghman | 2009-10-27 15:16:49 -0500 (Tue, 27 Oct 2009) | 7 lines

    Manager output is not always NULL-terminated, so force a NULL at the end of the filestream.
    (closes issue #15495)
     Reported by: pdf
     Patches:
           20090916__issue15495.diff.txt uploaded by tilghman (license 14)
     Tested by: pdf
  ........
................

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

main/manager.c

index 23b4b80fc1f4f3f1f27f39af40a813f1f34b3024..192006614993384e0107cc895e36de0706899e13 100644 (file)
@@ -3674,9 +3674,12 @@ static struct ast_str *generic_http_callback(enum output_format format,
 
        if (s.f != NULL) {      /* have temporary output */
                char *buf;
-               size_t l = ftell(s.f);
+               size_t l;
                
-               if (l) {
+               /* Ensure buffer is NULL-terminated */
+               fprintf(s.f, "%c", 0);
+
+               if ((l = ftell(s.f))) {
                        if (MAP_FAILED == (buf = mmap(NULL, l, PROT_READ | PROT_WRITE, MAP_PRIVATE, s.fd, 0))) {
                                ast_log(LOG_WARNING, "mmap failed.  Manager output was not processed\n");
                        } else {