Change in libosmocore[master]: cosmetic: osmo-sim-test.c: use memcpy instead of strncpy

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 Hofmeyr gerrit-no-reply at lists.osmocom.org
Thu Jul 26 15:24:00 UTC 2018


Neels Hofmeyr has uploaded this change for review. ( https://gerrit.osmocom.org/10176


Change subject: cosmetic: osmo-sim-test.c: use memcpy instead of strncpy
......................................................................

cosmetic: osmo-sim-test.c: use memcpy instead of strncpy

gcc 8.1.0 complains that the terminating \0 is not copied by strncpy, while
this code intends to do exactly that. Use memcpy instead.

Change-Id: I8d66fa22502c04d11ae153b9856d7e54f3492dd6
---
M utils/osmo-sim-test.c
1 file changed, 2 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/76/10176/1

diff --git a/utils/osmo-sim-test.c b/utils/osmo-sim-test.c
index ea24120..5588294 100644
--- a/utils/osmo-sim-test.c
+++ b/utils/osmo-sim-test.c
@@ -74,7 +74,8 @@
 	msg = osim_new_apdumsg(0x00, 0x20, 0x00, pin_nr, 8, 0);
 	pindst = (char *) msgb_put(msg, 8);
 	memset(pindst, 0xFF, 8);
-	strncpy(pindst, pin, strlen(pin));
+	/* Do not copy the terminating \0 */
+	memcpy(pindst, pin, strlen(pin));
 
 	return osim_transceive_apdu(st, msg);
 }

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8d66fa22502c04d11ae153b9856d7e54f3492dd6
Gerrit-Change-Number: 10176
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180726/5c71de5e/attachment.htm>


More information about the gerrit-log mailing list