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/jpeg.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'image/jpeg.c') diff --git a/image/jpeg.c b/image/jpeg.c index 7c68fb668..fd18238f7 100644 --- a/image/jpeg.c +++ b/image/jpeg.c @@ -289,7 +289,7 @@ static bool nsjpeg_convert(struct content *c) union content_msg_data msg_data; const char *data; unsigned long size; - char title[512]; + char *title; /* check image header is valid and get width/height */ data = content__get_source_data(c, &size); @@ -325,10 +325,14 @@ static bool nsjpeg_convert(struct content *c) image_cache_add(c, NULL, jpeg_cache_convert); - snprintf(title, sizeof(title), messages_get("JPEGTitle"), + /* set title text */ + title = messages_get_buff("JPEGTitle", 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); + } content_set_ready(c); content_set_done(c); -- cgit v1.2.3