Change in libosmocore[master]: gprs_ns2_fr.c: compiler error: replace strncpy() with OSMO_STRLCPY_AR...

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

neels gerrit-no-reply at lists.osmocom.org
Thu Dec 17 17:16:11 UTC 2020


neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/21779 )


Change subject: gprs_ns2_fr.c: compiler error: replace strncpy() with OSMO_STRLCPY_ARRAY()
......................................................................

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
---
M src/gb/gprs_ns2_fr.c
1 file changed, 1 insertion(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/79/21779/1

diff --git a/src/gb/gprs_ns2_fr.c b/src/gb/gprs_ns2_fr.c
index 8147f66..6f9cd8d 100644
--- a/src/gb/gprs_ns2_fr.c
+++ b/src/gb/gprs_ns2_fr.c
@@ -296,8 +296,7 @@
 
 
 	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);

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/21779
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I494a6fb7ccd7938a39e8956f73ec4282da38d7fb
Gerrit-Change-Number: 21779
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201217/38604b8e/attachment.htm>


More information about the gerrit-log mailing list