aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2012-01-17 15:58:48 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2012-01-17 15:58:48 +0100
commit9592c45e347076e0863dbd00fdc6e21bc0b98ec3 (patch)
treeb539674aabc2f5db8bc52ecdbe47a5f276f6e424
parent523a99d3a61eaeb0d868da063186778820c434fc (diff)
mgcp: Provide documentation for the method, check sscanf return
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
index 9ac54dabe..62bf183fa 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
@@ -507,6 +507,9 @@ uint32_t bsc_mgcp_extract_ci(const char *str)
return ci;
}
+/**
+ * Create a new MGCPCommand based on the input and endpoint from a message
+ */
static void patch_mgcp(struct msgb *output, const char *op, const char *tok,
int endp, int len, int cr)
{
@@ -516,6 +519,11 @@ static void patch_mgcp(struct msgb *output, const char *op, const char *tok,
buf[0] = buf[39] = '\0';
ret = sscanf(tok, "%*s %s", buf);
+ if (ret != 1) {
+ LOGP(DMGCP, LOGL_ERROR,
+ "Failed to find Endpoint in: %s\n", tok);
+ return;
+ }
slen = sprintf((char *) output->l3h, "%s %s %x@mgw MGCP 1.0%s",
op, buf, endp, cr ? "\r\n" : "\n");