Review at  https://gerrit.osmocom.org/5024

client: use osmo_strlcpy instead of strncpy

simplify null termination of the ip_addr string

Change-Id: I94e3815f45d08e0d40faf41e580547de937c4ce8
---
M src/libosmo-mgcp-client/mgcp_client.c
M src/libosmo-mgcp/mgcp_conn.c
2 files changed, 3 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/24/5024/1

diff --git a/src/libosmo-mgcp-client/mgcp_client.c 
b/src/libosmo-mgcp-client/mgcp_client.c
index ac86f52..4b2ee91 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -201,8 +201,7 @@
                goto response_parse_failure;
 
        /* Extract IP-Address */
-       strncpy(r->audio_ip, line + 9, sizeof(r->audio_ip));
-       r->audio_ip[sizeof(r->audio_ip) - 1] = '\0';
+       osmo_strlcpy(r->audio_ip, line + 9, sizeof(r->audio_ip));
 
        /* Check IP-Address */
        if (inet_aton(r->audio_ip, &ip_test) == 0)
diff --git a/src/libosmo-mgcp/mgcp_conn.c b/src/libosmo-mgcp/mgcp_conn.c
index f65395b..b90a2b5 100644
--- a/src/libosmo-mgcp/mgcp_conn.c
+++ b/src/libosmo-mgcp/mgcp_conn.c
@@ -29,7 +29,8 @@
 #include <ctype.h>
 
 /* Allocate a new connection identifier. According to RFC3435, they must
- * be unique only within the scope of the endpoint. */
+ * be unique only within the scope of the endpoint. (Caller must provide
+ * memory for id) */
 static int mgcp_alloc_id(struct mgcp_endpoint *endp, char *id)
 {
        int i;

-- 
To view, visit https://gerrit.osmocom.org/5024
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I94e3815f45d08e0d40faf41e580547de937c4ce8
Gerrit-PatchSet: 1
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter <[email protected]>

Reply via email to