[MERGED] osmo-msc[master]: msc_mgcp: use more conceise error msg on truncation

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
Wed Mar 14 21:04:59 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: msc_mgcp: use more conceise error msg on truncation
......................................................................


msc_mgcp: use more conceise error msg on truncation

When a truncation check (osmo_strlcpy()) fails handle_error()
is called with MGCP_ERR_NOMEM as cause code. Which finally
results in an "out of memory" message. MGCP_ERR_NOMEM is only
used for failed truncation checks, so it makes sense to choose
a message that describes the cause of the problem better.

- rename MGCP_ERR_NOMEM to MGCP_ERR_TOOLONG
- replace error message string

Change-Id: Ifedb85c1933a30b2aa491b495119919f45782e2c
---
M src/libmsc/msc_mgcp.c
1 file changed, 7 insertions(+), 7 deletions(-)

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



diff --git a/src/libmsc/msc_mgcp.c b/src/libmsc/msc_mgcp.c
index 0790b2b..541ff0a 100644
--- a/src/libmsc/msc_mgcp.c
+++ b/src/libmsc/msc_mgcp.c
@@ -63,7 +63,7 @@
 	MGCP_ERR_UNSUPP_ADDR_FMT,
 	MGCP_ERR_RAN_TIMEOUT,
 	MGCP_ERR_ASS_TIMEOUT,
-	MGCP_ERR_NOMEM,
+	MGCP_ERR_TOOLONG,
 	MGCP_ERR_ASSGMNT_FAIL
 };
 
@@ -78,7 +78,7 @@
 	{MGCP_ERR_UNSUPP_ADDR_FMT, "unsupported network address format used (RAN)"},
 	{MGCP_ERR_RAN_TIMEOUT, "call could not be completed in time (RAN)"},
 	{MGCP_ERR_ASS_TIMEOUT, "assignment could not be completed in time (RAN)"},
-	{MGCP_ERR_NOMEM, "out of memory"},
+	{MGCP_ERR_TOOLONG, "string value too long"},
 	{MGCP_ERR_ASSGMNT_FAIL, "assignment failure (RAN)"},
 	{0, NULL}
 };
@@ -285,7 +285,7 @@
 	};
 	if (snprintf(mgcp_msg.endpoint, MGCP_ENDPOINT_MAXLEN, MGCP_ENDPOINT_FORMAT, mgcp_ctx->rtp_endpoint) >=
 	    MGCP_ENDPOINT_MAXLEN) {
-		handle_error(mgcp_ctx, MGCP_ERR_NOMEM, true);
+		handle_error(mgcp_ctx, MGCP_ERR_TOOLONG, true);
 		return;
 	}
 	msg = mgcp_msg_gen(mgcp, &mgcp_msg);
@@ -378,7 +378,7 @@
 	};
 	if (snprintf(mgcp_msg.endpoint, MGCP_ENDPOINT_MAXLEN, MGCP_ENDPOINT_FORMAT, mgcp_ctx->rtp_endpoint) >=
 	    MGCP_ENDPOINT_MAXLEN) {
-		handle_error(mgcp_ctx, MGCP_ERR_NOMEM, true);
+		handle_error(mgcp_ctx, MGCP_ERR_TOOLONG, true);
 		return;
 	}
 	msg = mgcp_msg_gen(mgcp, &mgcp_msg);
@@ -541,7 +541,7 @@
 	};
 	if (snprintf(mgcp_msg.endpoint, MGCP_ENDPOINT_MAXLEN, MGCP_ENDPOINT_FORMAT, mgcp_ctx->rtp_endpoint) >=
 	    MGCP_ENDPOINT_MAXLEN) {
-		handle_error(mgcp_ctx, MGCP_ERR_NOMEM, true);
+		handle_error(mgcp_ctx, MGCP_ERR_TOOLONG, true);
 		return;
 	}
 	msg = mgcp_msg_gen(mgcp, &mgcp_msg);
@@ -657,7 +657,7 @@
 	};
 	if (snprintf(mgcp_msg.endpoint, MGCP_ENDPOINT_MAXLEN, MGCP_ENDPOINT_FORMAT, mgcp_ctx->rtp_endpoint) >=
 	    MGCP_ENDPOINT_MAXLEN) {
-		handle_error(mgcp_ctx, MGCP_ERR_NOMEM, true);
+		handle_error(mgcp_ctx, MGCP_ERR_TOOLONG, true);
 		return;
 	}
 	msg = mgcp_msg_gen(mgcp, &mgcp_msg);
@@ -741,7 +741,7 @@
 	};
 	if (snprintf(mgcp_msg.endpoint, MGCP_ENDPOINT_MAXLEN, MGCP_ENDPOINT_FORMAT, mgcp_ctx->rtp_endpoint) >=
 	    MGCP_ENDPOINT_MAXLEN) {
-		handle_error(mgcp_ctx, MGCP_ERR_NOMEM, true);
+		handle_error(mgcp_ctx, MGCP_ERR_TOOLONG, true);
 		return;
 	}
 	msg = mgcp_msg_gen(mgcp, &mgcp_msg);

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifedb85c1933a30b2aa491b495119919f45782e2c
Gerrit-PatchSet: 3
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list