From 212d0c4c7614c2ec2796dd21ab240c2d70743a1e Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Fri, 27 Oct 2017 17:59:21 +0200 Subject: osmo_sccp_addr_encode(): Catch some more errors and log them Log errors in case the user provides global title indicators or nature-of-address indicators that exceed the permitted value range Change-Id: I493b7810bdc58e448f496565ded36f9dce2c1226 --- src/sccp2sua.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/sccp2sua.c b/src/sccp2sua.c index ac2b2c2..d97906e 100644 --- a/src/sccp2sua.c +++ b/src/sccp2sua.c @@ -262,6 +262,16 @@ int osmo_sccp_addr_encode(struct msgb *msg, const struct osmo_sccp_addr *in) goto out; } + if (in->gt.npi && (in->gt.npi > 0xF)) { + LOGP(DLSUA, LOGL_ERROR, "Unsupported Numbering Plan %u", in->gt.npi); + return -EINVAL; + } + + if (in->gt.nai && (in->gt.nai > 0x7F)) { + LOGP(DLSUA, LOGL_ERROR, "Unsupported Nature of Address %u", in->gt.nai); + return -EINVAL; + } + odd = strlen(in->gt.digits) & 1; switch (in->gt.gti) { case OSMO_SCCP_GTI_NO_GT: -- cgit v1.2.3