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/png.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'image/png.c') diff --git a/image/png.c b/image/png.c index 99482d63d..23c755825 100644 --- a/image/png.c +++ b/image/png.c @@ -510,7 +510,7 @@ png_cache_convert_error: static bool nspng_convert(struct content *c) { nspng_content *png_c = (nspng_content *) c; - char title[512]; + char *title; assert(png_c->png != NULL); assert(png_c->info != NULL); @@ -519,11 +519,13 @@ static bool nspng_convert(struct content *c) png_destroy_read_struct(&png_c->png, &png_c->info, 0); /* set title text */ - snprintf(title, sizeof(title), messages_get("PNGTitle"), + 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); + } if (png_c->bitmap != NULL) { bitmap_set_opaque(png_c->bitmap, bitmap_test_opaque(png_c->bitmap)); -- cgit v1.2.3