Change in libosmo-abis[master]: fix strncpy bugs in ipaccess.c, ipa_proxy.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/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Thu Jul 26 15:28:51 UTC 2018


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


Change subject: fix strncpy bugs in ipaccess.c, ipa_proxy.c
......................................................................

fix strncpy bugs in ipaccess.c, ipa_proxy.c

Change-Id: Iad53b603521c0a8f4857bd87dca777ba8e875cde
---
M src/input/ipaccess.c
M src/ipa_proxy.c
2 files changed, 6 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/77/10177/1

diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c
index 23eeda6..7d3845e 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -602,19 +602,19 @@
 			break;
 		case IPAC_IDTAG_LOCATION1:
 			if (dev->location1)
-				strncpy(str, dev->location1, IPA_STRING_MAX);
+				osmo_strlcpy(str, dev->swversion, sizeof(str));
 			break;
 		case IPAC_IDTAG_LOCATION2:
 			if (dev->location2)
-				strncpy(str, dev->location2, IPA_STRING_MAX);
+				osmo_strlcpy(str, dev->swversion, sizeof(str));
 			break;
 		case IPAC_IDTAG_EQUIPVERS:
 			if (dev->equipvers)
-				strncpy(str, dev->equipvers, IPA_STRING_MAX);
+				osmo_strlcpy(str, dev->swversion, 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:
 			snprintf(str, sizeof(str),
@@ -626,7 +626,7 @@
 			break;
 		case IPAC_IDTAG_SERNR:
 			if (dev->serno)
-				strncpy(str, dev->serno, IPA_STRING_MAX);
+				osmo_strlcpy(str, dev->swversion, sizeof(str));
 			break;
 		default:
 			LOGP(DLINP, LOGL_NOTICE,
@@ -634,7 +634,6 @@
 			msgb_free(nmsg);
 			return NULL;
 		}
-		str[IPA_STRING_MAX-1] = '\0';
 
 		LOGP(DLINP, LOGL_INFO, " tag %d: %s\n", data[1], str);
 		tag = msgb_put(nmsg, 3 + strlen(str) + 1);
diff --git a/src/ipa_proxy.c b/src/ipa_proxy.c
index 94f48dc..44f5baf 100644
--- a/src/ipa_proxy.c
+++ b/src/ipa_proxy.c
@@ -245,8 +245,7 @@
 			VTY_NEWLINE);
 		return CMD_WARNING;
 	}
-	strncpy(ipi->name, argv[0], IPA_INSTANCE_NAME);
-	ipi->name[IPA_INSTANCE_NAME - 1] = '\0';
+	osmo_strlcpy(ipi->name, argv[0], sizeof(ipi->name));
 	ipi->net.type = type;
 	ipi->net.addr = talloc_strdup(tall_ipa_proxy_ctx, argv[2]);
 	ipi->net.port = port;

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

Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iad53b603521c0a8f4857bd87dca777ba8e875cde
Gerrit-Change-Number: 10177
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/4caa5c3a/attachment.htm>


More information about the gerrit-log mailing list