mirror of
https://github.com/asterisk/asterisk.git
synced 2026-01-03 13:04:32 +00:00
Off-by-one error
(closes issue #16506) Reported by: nik600 Patches: 20100629__issue16506.diff.txt uploaded by tilghman (license 14) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@278023 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -2917,14 +2917,12 @@ static char *generic_http_callback(int format, struct sockaddr_in *requestor, co
|
||||
char *buf;
|
||||
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))) {
|
||||
if (MAP_FAILED == (buf = mmap(NULL, l + 1, PROT_READ | PROT_WRITE, MAP_SHARED, 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)
|
||||
@@ -2945,7 +2943,7 @@ static char *generic_http_callback(int format, struct sockaddr_in *requestor, co
|
||||
free(tmpbuf);
|
||||
free(s->outputstr);
|
||||
s->outputstr = NULL;
|
||||
munmap(buf, l);
|
||||
munmap(buf, l + 1);
|
||||
}
|
||||
}
|
||||
fclose(ss.f);
|
||||
|
||||
Reference in New Issue
Block a user