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/ico.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'image/ico.c') diff --git a/image/ico.c b/image/ico.c index ff8f9204c..e455a59d9 100644 --- a/image/ico.c +++ b/image/ico.c @@ -100,7 +100,7 @@ static bool nsico_convert(struct content *c) union content_msg_data msg_data; const char *data; unsigned long size; - char title[512]; + char *title; /* set the ico data */ data = content__get_source_data(c, &size); @@ -122,14 +122,19 @@ static bool nsico_convert(struct content *c) return false; } - /* Store our content width and description */ + /* Store our content width, height and calculate size */ c->width = ico->ico->width; c->height = ico->ico->height; - snprintf(title, sizeof(title), messages_get("ICOTitle"), + c->size += (ico->ico->width * ico->ico->height * 4) + 16 + 44; + + /* set title text */ + title = messages_get_buff("ICOTitle", nsurl_access_leaf(llcache_handle_get_url(c->llcache)), c->width, c->height); - content__set_title(c, title); - c->size += (ico->ico->width * ico->ico->height * 4) + 16 + 44; + if (title != NULL) { + content__set_title(c, title); + free(title); + } /* select largest icon to ensure one can be selected */ bmp = ico_find(ico->ico, 255, 255); -- cgit v1.2.3