diff options
author | Thomas Haller <thaller@redhat.com> | 2020-04-15 14:25:19 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-04-15 16:39:27 (GMT) |
commit | a858a0bc5649da77fc119ebe7b9f0e4a96825ebe (patch) | |
tree | 3bbc381d77437eb37b64d86fadd9e1bed42bce18 /lib/utils.c | |
parent | 018c694ad42af6dd082eff7f323bd6a2c57ca80f (diff) | |
download | libnl-a858a0bc5649da77fc119ebe7b9f0e4a96825ebe.zip libnl-a858a0bc5649da77fc119ebe7b9f0e4a96825ebe.tar.gz libnl-a858a0bc5649da77fc119ebe7b9f0e4a96825ebe.tar.bz2 |
lib: use _nl_strncpy*() instead of plain strncpy()
There wasn't really a bug previously, but it's ugly and raises
questions about the correct use of strncpy().
For example,
void genl_family_set_name(struct genl_family *family, const char *name)
{
strncpy(family->gf_name, name, GENL_NAMSIZ-1);
was in fact correct, because family->gf_name will (presumably) always have a NUL
character as last position.
Still use _nl_strncpy*() wrappers, to avoid raising such questions.
Diffstat (limited to 'lib/utils.c')
-rw-r--r-- | lib/utils.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/utils.c b/lib/utils.c index 496bf3b..9bfbb08 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -475,7 +475,7 @@ static void get_psched_settings(void) else if ((ev = getenv("PROC_ROOT"))) snprintf(name, sizeof(name), "%s/net/psched", ev); else - strncpy(name, "/proc/net/psched", sizeof(name) - 1); + _nl_strncpy_assert(name, "/proc/net/psched", sizeof(name)); if ((fd = fopen(name, "re"))) { unsigned int ns_per_usec, ns_per_tick, nom, denom; |