Skip to content

Commit

Permalink
Cnode: replace strcpy with strncpy
Browse files Browse the repository at this point in the history
  • Loading branch information
rinpatch committed Oct 24, 2019
1 parent 6e70eb6 commit 7a6372a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions c_src/myhtml_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,10 @@ ETERM* build_tree(prefab_t* prefab, myhtml_tree_t* tree, myhtml_tree_node_t* nod
if (tag_ns != MyHTML_NAMESPACE_HTML)
{
// tag_ns_name_ptr is unmodifyable, copy it in our tag_ns_buffer to make it modifyable.
char tag_ns_buffer[tag_ns_len];
strcpy(tag_ns_buffer, tag_ns_name_ptr);
// +1 because myhtml uses strlen for length returned, which doesn't include the null-byte
// https://github.com/lexborisov/myhtml/blob/0ade0e564a87f46fd21693a7d8c8d1fa09ffb6b6/source/myhtml/mynamespace.c#L80
char tag_ns_buffer[tag_ns_len + 1];
strncpy(tag_ns_buffer, tag_ns_name_ptr, sizeof(tag_ns_buffer));
lowercase(tag_ns_buffer);

tag_string_len = tag_ns_len + tag_name_len + 1; // +1 for colon
Expand Down

0 comments on commit 7a6372a

Please sign in to comment.