diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2020-12-17 18:10:34 +0100 |
---|---|---|
committer | laforge <laforge@osmocom.org> | 2020-12-18 11:12:16 +0000 |
commit | 475a0acc64efb4b3de47d2f234eb67886a4fa7fe (patch) | |
tree | 644fe548d60dc1e8856352b2ef53df3fb9c3531a /src/gb | |
parent | 6f89c770c7bd6ed4919375c31e18de7c17a8a61f (diff) |
gprs_ns2_fr.c: compiler error: replace strncpy() with OSMO_STRLCPY_ARRAY()
My gcc (Debian 8.3.0-6) 8.3.0 refuses to build this strncpy() use: it
issues the buffer length as n and thus potentially fails to account for
the terminating nul. The line after that fixes the problem, so it's not
an actual bug. Anyway, we have a policy to never use strncpy(), and have
osmo_strlcpy() and OSMO_STRLCPY_ARRAY() for this.
This strncpy() was introduced last month during first addition of
gprs_ns2_fr.c:
commit 841817ec52186029ca01f0c082ed84f2dc5ffcc5
ns2: add support for frame relay
Change-Id Id3b49f93d33c271f77cd9c9db03cde6b727a4d30
Change-Id: I494a6fb7ccd7938a39e8956f73ec4282da38d7fb
Diffstat (limited to 'src/gb')
-rw-r--r-- | src/gb/gprs_ns2_fr.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/gb/gprs_ns2_fr.c b/src/gb/gprs_ns2_fr.c index fc6f1662..1ff80ed0 100644 --- a/src/gb/gprs_ns2_fr.c +++ b/src/gb/gprs_ns2_fr.c @@ -296,8 +296,7 @@ static int devname2ifindex(const char *ifname) memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); - ifr.ifr_name[sizeof(ifr.ifr_name)-1] = 0; + OSMO_STRLCPY_ARRAY(ifr.ifr_name, ifname); rc = ioctl(sk, SIOCGIFINDEX, &ifr); close(sk); |