Close file after we do the translation, and map memory for both reading/writing. (issue #8886 reported by cwegener)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@51831 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Joshua Colp
2007-01-24 00:22:50 +00:00
parent 19a8da7bed
commit 68c1f5338f

View File

@@ -2820,10 +2820,9 @@ static struct ast_str *generic_http_callback(enum output_format format,
char *buf;
size_t l = ftell(s->f);
fclose(s->f);
if (format == FORMAT_XML || format == FORMAT_HTML) {
if (l) {
if ((buf = mmap(NULL, l, PROT_READ, MAP_SHARED, s->fd, 0))) {
if ((buf = mmap(NULL, l, PROT_READ | PROT_WRITE, MAP_SHARED, s->fd, 0))) {
xml_translate(&out, buf, params, format);
munmap(buf, l);
}
@@ -2831,6 +2830,7 @@ static struct ast_str *generic_http_callback(enum output_format format,
xml_translate(&out, "", params, format);
}
}
fclose(s->f);
s->f = NULL;
s->fd = -1;
}