summaryrefslogtreecommitdiff
path: root/image/ico.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/ico.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/ico.c')
-rw-r--r--image/ico.c15
1 files changed, 10 insertions, 5 deletions
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);