summaryrefslogtreecommitdiff
path: root/image/mng.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2012-10-25 11:12:41 +0100
committerVincent Sanders <vince@netsurf-browser.org>2012-10-25 11:12:41 +0100
commitbaf50cec89d10055217a3bb210d389694fb1d389 (patch)
tree98ba96f23f98ceecaf02fbc2e016b297a50c9a25 /image/mng.c
parent0b7db9b47adaf56ae937415040cf585a07eaf8cb (diff)
downloadnetsurf-baf50cec89d10055217a3bb210d389694fb1d389.tar.gz
netsurf-baf50cec89d10055217a3bb210d389694fb1d389.tar.bz2
make image content handlers title setting use the heap instead of the stack and remove the possibility of buffer overruns
Diffstat (limited to 'image/mng.c')
-rw-r--r--image/mng.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/image/mng.c b/image/mng.c
index 9ca9a2d48..518dc8552 100644
--- a/image/mng.c
+++ b/image/mng.c
@@ -541,7 +541,7 @@ static bool nsmng_convert(struct content *c)
nsmng_content *mng = (nsmng_content *) c;
mng_retcode status;
unsigned long size;
- char title[512];
+ char *title;
assert(c != NULL);
@@ -554,12 +554,15 @@ static bool nsmng_convert(struct content *c)
return nsmng_broadcast_error(mng, -1) == NSERROR_OK;
}
- /* Set the title
- */
- snprintf(title, sizeof(title), messages_get("MNGTitle"),
+
+ /* set title text */
+ title = messages_get_buff("MNGTitle",
nsurl_access_leaf(llcache_handle_get_url(c->llcache)),
c->width, c->height);
- content__set_title(c, title);
+ if (title != NULL) {
+ content__set_title(c, title);
+ free(title);
+ }
c->size += c->width * c->height * 4;
content_set_ready(c);
@@ -599,7 +602,7 @@ static bool nsjpng_convert(struct content *c)
nsmng_content *mng = (nsmng_content *) c;
mng_retcode status;
unsigned long size;
- char title[512];
+ char *title;
mng_handle handle;
assert(c != NULL);
@@ -613,11 +616,14 @@ static bool nsjpng_convert(struct content *c)
return nsmng_broadcast_error(mng, -1) == NSERROR_OK;
}
- /* Set the title */
- snprintf(title, sizeof(title), messages_get("PNGTitle"),
+ /* set title text */
+ title = messages_get_buff("PNGTitle",
nsurl_access_leaf(llcache_handle_get_url(c->llcache)),
c->width, c->height);
- content__set_title(c, title);
+ if (title != NULL) {
+ content__set_title(c, title);
+ free(title);
+ }
c->size += c->width * c->height * 4;
content_set_ready(c);