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
1 changed files with 11 additions and 5 deletions

View File

@ -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) {