From baf50cec89d10055217a3bb210d389694fb1d389 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 25 Oct 2012 11:12:41 +0100 Subject: make image content handlers title setting use the heap instead of the stack and remove the possibility of buffer overruns --- image/mng.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'image/mng.c') 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); -- cgit v1.2.3