From 5dd5d5da4b1cc8cdb780559f8e1ea0d058b27b20 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Fri, 24 Aug 2018 10:26:26 +0100 Subject: remove warning by replacing strcpy with safer strncpy --- content/handlers/html/imagemap.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'content/handlers/html') diff --git a/content/handlers/html/imagemap.c b/content/handlers/html/imagemap.c index 5f4dd54b3..d26ba5f4d 100644 --- a/content/handlers/html/imagemap.c +++ b/content/handlers/html/imagemap.c @@ -299,8 +299,11 @@ void imagemap_dump(html_content *c) * \return false on memory exhaustion, true otherwise */ static bool -imagemap_addtolist(const struct html_content *c, dom_node *n, nsurl *base_url, - struct mapentry **entry, dom_string *tagtype) +imagemap_addtolist(const struct html_content *c, + dom_node *n, + nsurl *base_url, + struct mapentry **entry, + dom_string *tagtype) { dom_exception exc; dom_string *href = NULL, *target = NULL, *shape = NULL; @@ -377,9 +380,12 @@ imagemap_addtolist(const struct html_content *c, dom_node *n, nsurl *base_url, new_map->target = malloc(dom_string_byte_length(target) + 1); if (new_map->target == NULL) goto bad_out; - /* Safe, but relies on dom_strings being NULL terminated */ - /* \todo Do this better */ - strcpy(new_map->target, dom_string_data(target)); + + strncpy(new_map->target, + dom_string_data(target), + dom_string_byte_length(target)); + + new_map->target[dom_string_byte_length(target)] = 0; } if (new_map->type != IMAGEMAP_DEFAULT) { -- cgit v1.2.3