Index: main/manager.c =================================================================== --- main/manager.c (revision 317194) +++ main/manager.c (working copy) @@ -2990,12 +2990,14 @@ char *buf; size_t l; - if ((l = lseek(ss.fd, 0, SEEK_END)) > 0) { - if (MAP_FAILED == (buf = mmap(NULL, l + 1, PROT_READ | PROT_WRITE, MAP_SHARED, ss.fd, 0))) { + /* Make sure we have room at the end for a terminating NULL */ + fputc(0, ss.f); + + if ((l = ftell(ss.f))) { + 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 { char *tmpbuf; - buf[l] = '\0'; if (format == FORMAT_XML) tmpbuf = xml_translate(buf, params); else if (format == FORMAT_HTML) @@ -3016,7 +3018,7 @@ free(tmpbuf); free(s->outputstr); s->outputstr = NULL; - munmap(buf, l + 1); + munmap(buf, l); } } fclose(ss.f);