[USSD] various USSD improvements
- Improved handling of extension-number string (as per review)
- Guard against a buffer-overflow if mobile sends a too-long USSD
- declare some function-parameters const
- fix gsm_ts_name function to display the right BTS number (bts->nr rather than bts->bts_nr)
diff --git a/openbsc/src/ussd.c b/openbsc/src/ussd.c
index e414b1c..a3d11f0 100644
--- a/openbsc/src/ussd.c
+++ b/openbsc/src/ussd.c
@@ -63,9 +63,9 @@
static int send_own_number(const struct msgb *msg, const struct ussd_request *req)
{
char *own_number = msg->lchan->subscr->extension;
- /* Need trailing CR as EOT character */
- char response_string[] = "Your extension is xxxxx\r";
+ char response_string[GSM_EXTENSION_LENGTH + 20];
- memcpy(response_string + 18, own_number, 5);
+ /* Need trailing CR as EOT character */
+ snprintf(response_string, sizeof(response_string), "Your extension is %s\r", own_number);
return gsm0480_send_ussd_response(msg, response_string, req);
}