]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Manager output is not always NULL-terminated, so force a NULL at the end of the files...
authorTilghman Lesher <tilghman@meg.abyt.es>
Tue, 27 Oct 2009 20:16:49 +0000 (20:16 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Tue, 27 Oct 2009 20:16:49 +0000 (20:16 +0000)
(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.4@226138 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/manager.c

index 73a66f0bd9639579a90d5800de0a53cc3ef65c4d..67e4a4f74056577a49277fe370e696b196a4e590 100644 (file)
@@ -2882,8 +2882,12 @@ static char *generic_http_callback(int format, struct sockaddr_in *requestor, co
                ast_mutex_lock(&s->__lock);
                if (ss.fd > -1) {
                        char *buf;
-                       size_t l = lseek(ss.fd, 0, SEEK_END);
-                       if (l) {
+                       size_t l;
+
+                       /* Ensure buffer is NULL-terminated */
+                       fprintf(ss.f, "%c", 0);
+
+                       if ((l = lseek(ss.fd, 0, SEEK_END)) > 0) {
                                if (MAP_FAILED == (buf = mmap(NULL, l, PROT_READ | PROT_WRITE, MAP_PRIVATE, ss.fd, 0))) {
                                        ast_log(LOG_WARNING, "mmap failed.  Manager request output was not processed\n");
                                } else {