Harald Welte has submitted this change and it was merged. ( 
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(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



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: merged
Gerrit-Change-Id: Iad53b603521c0a8f4857bd87dca777ba8e875cde
Gerrit-Change-Number: 10177
Gerrit-PatchSet: 2
Gerrit-Owner: Neels Hofmeyr <[email protected]>
Gerrit-Reviewer: Harald Welte <[email protected]>
Gerrit-Reviewer: Jenkins Builder

Reply via email to