remove warning by replacing strcpy with safer strncpy

This commit is contained in:
Vincent Sanders 2018-08-24 10:26:26 +01:00
parent 865796486d
commit 5dd5d5da4b

View File

@ -299,8 +299,11 @@ void imagemap_dump(html_content *c)
* \return false on memory exhaustion, true otherwise * \return false on memory exhaustion, true otherwise
*/ */
static bool static bool
imagemap_addtolist(const struct html_content *c, dom_node *n, nsurl *base_url, imagemap_addtolist(const struct html_content *c,
struct mapentry **entry, dom_string *tagtype) dom_node *n,
nsurl *base_url,
struct mapentry **entry,
dom_string *tagtype)
{ {
dom_exception exc; dom_exception exc;
dom_string *href = NULL, *target = NULL, *shape = NULL; 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); new_map->target = malloc(dom_string_byte_length(target) + 1);
if (new_map->target == NULL) if (new_map->target == NULL)
goto bad_out; goto bad_out;
/* Safe, but relies on dom_strings being NULL terminated */
/* \todo Do this better */ strncpy(new_map->target,
strcpy(new_map->target, dom_string_data(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) { if (new_map->type != IMAGEMAP_DEFAULT) {