Change in libosmocore[master]: fix strncpy bugs in gsm/ipa.c

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Fri Jul 27 18:15:44 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/10174 )

Change subject: fix strncpy bugs in gsm/ipa.c
......................................................................

fix strncpy bugs in gsm/ipa.c

Change-Id: I423a24c55c9b9aa6fc8f501df94fe54c71ee2b2b
---
M src/gsm/ipa.c
1 file changed, 6 insertions(+), 7 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Pau Espin Pedrol: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/src/gsm/ipa.c b/src/gsm/ipa.c
index 0c7aaad..aecde83 100644
--- a/src/gsm/ipa.c
+++ b/src/gsm/ipa.c
@@ -251,23 +251,23 @@
 			break;
 		case IPAC_IDTAG_LOCATION1:
 			if (dev->location1)
-				strncpy(str, dev->location1, IPA_STRING_MAX);
+				osmo_strlcpy(str, dev->location1, sizeof(str));
 			break;
 		case IPAC_IDTAG_LOCATION2:
 			if (dev->location2)
-				strncpy(str, dev->location2, IPA_STRING_MAX);
+				osmo_strlcpy(str, dev->location2, sizeof(str));
 			break;
 		case IPAC_IDTAG_EQUIPVERS:
 			if (dev->equipvers)
-				strncpy(str, dev->equipvers, IPA_STRING_MAX);
+				osmo_strlcpy(str, dev->equipvers, sizeof(str));
 			break;
 		case IPAC_IDTAG_SWVERSION:
 			if (dev->swversion)
-				strncpy(str, dev->swversion, IPA_STRING_MAX);
+				osmo_strlcpy(str, dev->swversion, sizeof(str));
 			break;
 		case IPAC_IDTAG_UNITNAME:
 			if (dev->unit_name) {
-				snprintf(str, sizeof(str), dev->unit_name, IPA_STRING_MAX);
+				snprintf(str, sizeof(str), "%s", dev->unit_name);
 			} else {
 				snprintf(str, sizeof(str),
 					 "%02x-%02x-%02x-%02x-%02x-%02x",
@@ -278,7 +278,7 @@
 			break;
 		case IPAC_IDTAG_SERNR:
 			if (dev->serno)
-				strncpy(str, dev->serno, IPA_STRING_MAX);
+				osmo_strlcpy(str, dev->serno, sizeof(str));
 			break;
 		default:
 			LOGP(DLINP, LOGL_NOTICE,
@@ -286,7 +286,6 @@
 			msgb_free(msg);
 			return NULL;
 		}
-		str[IPA_STRING_MAX-1] = '\0';
 
 		LOGP(DLINP, LOGL_INFO, " tag %d: %s\n", ies_req[i], str);
 		tag = msgb_put(msg, 3 + strlen(str) + 1);

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I423a24c55c9b9aa6fc8f501df94fe54c71ee2b2b
Gerrit-Change-Number: 10174
Gerrit-PatchSet: 4
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180727/af56ae80/attachment.htm>


More information about the gerrit-log mailing list