diff --git a/main/manager.c b/main/manager.c index a02d06106d..1983ddeb20 100644 --- a/main/manager.c +++ b/main/manager.c @@ -4878,9 +4878,12 @@ static int generic_http_callback(struct ast_tcptls_session_instance *ser, 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 {