Some simple size check. We would not overflow but would send garbage
Check the size
This commit is contained in:
parent
ca64da984b
commit
5e76ce61ac
|
@ -204,12 +204,19 @@ void telnet_send_gsm_48(struct telnet_connection *connection) {
|
||||||
static const char* error[] = {
|
static const char* error[] = {
|
||||||
"48: IMSI not found\n",
|
"48: IMSI not found\n",
|
||||||
"48: No channel allocated for IMSI\n" };
|
"48: No channel allocated for IMSI\n" };
|
||||||
|
int ret;
|
||||||
struct gsm_bts *bts = &connection->network->bts[connection->bts];
|
struct gsm_bts *bts = &connection->network->bts[connection->bts];
|
||||||
struct gsm_lchan *lchan = find_channel(bts, connection->imsi, error, connection->fd.fd);
|
struct gsm_lchan *lchan = find_channel(bts, connection->imsi, error, connection->fd.fd);
|
||||||
|
|
||||||
if (!lchan)
|
if (!lchan)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (connection->read < 2) {
|
||||||
|
static const char *msg = "48: Need at least two bytes";
|
||||||
|
ret = write(connection->fd.fd, msg, strlen(msg));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct msgb *msg = gsm48_msgb_alloc();
|
struct msgb *msg = gsm48_msgb_alloc();
|
||||||
struct gsm48_hdr *gh;
|
struct gsm48_hdr *gh;
|
||||||
int i;
|
int i;
|
||||||
|
|
Loading…
Reference in New Issue