diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2018-07-26 17:28:24 +0200 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2018-07-27 18:51:30 +0200 |
commit | 4c57eef663e870247cb7a72130a50750317a44b9 (patch) | |
tree | e2ae53015cf0ee70b16bee874a55925c1847c29f | |
parent | 026ff4574daedcf91a474f9bc67e90e8537a9d86 (diff) |
fix strncpy bugs in ipaccess.c, ipa_proxy.c
Change-Id: Iad53b603521c0a8f4857bd87dca777ba8e875cde
-rw-r--r-- | src/input/ipaccess.c | 11 | ||||
-rw-r--r-- | src/ipa_proxy.c | 3 |
2 files changed, 6 insertions, 8 deletions
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 @@ ipa_bts_id_resp(const struct ipaccess_unit *dev, uint8_t *data, int len, int trx 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 @@ ipa_bts_id_resp(const struct ipaccess_unit *dev, uint8_t *data, int len, int trx 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 @@ ipa_bts_id_resp(const struct ipaccess_unit *dev, uint8_t *data, int len, int trx 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 @@ static int __ipa_instance_add(struct vty *vty, int argc, const char *argv[]) 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; |