osmux: Make sure that bigger Osmux ids actually fit
We put a signed integer into this string but did not account
for the newline and for the terminating NUL of the string. Add
the newline to the string and add one for NUL. Spotted while
accidently having a CID of 255.
diff --git a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
index 0105c7e..9fd9967 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
@@ -818,7 +818,7 @@
int slen;
int ret;
char buf[40];
- char osmux_extension[strlen("X-Osmux: 255")];
+ char osmux_extension[strlen("\nX-Osmux: 255") + 1];
buf[0] = buf[39] = '\0';
ret = sscanf(tok, "%*s %s", buf);
@@ -829,7 +829,7 @@
}
if (osmux_cid >= 0)
- sprintf(osmux_extension, "\nX-Osmux: %u", osmux_cid);
+ sprintf(osmux_extension, "\nX-Osmux: %u", osmux_cid & 0xff);
else
osmux_extension[0] = '\0';