Skip to content
Snippets Groups Projects
Commit bc91cb6e authored by Nick Mathewson's avatar Nick Mathewson :game_die:
Browse files

Use strlcpy when copying node IDs into measured_bw_line_t

We were using strncpy before, which isn't our style for stuff like
this.

This isn't a bug, though: before calling strncpy, we were checking
that strlen(src) was indeed == HEX_DIGEST_LEN, which is less than
sizeof(dst), so there was no way we could fail to NUL-terminate.
Still, strncpy(a,b,sizeof(a)) is an idiom that we ought to squash
everyplace.

Fixes CID #427.
parent 2b5ebc70
No related branches found
No related tags found
No related merge requests found
......@@ -2415,7 +2415,7 @@ measured_bw_line_parse(measured_bw_line_t *out, const char *orig_line)
tor_free(line);
return -1;
}
strncpy(out->node_hex, cp, sizeof(out->node_hex));
strlcpy(out->node_hex, cp, sizeof(out->node_hex));
got_node_id=1;
}
} while ((cp = tor_strtok_r(NULL, " \t", &strtok_state)));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment