Some simple size check. We would not overflow but would send garbage

Check the size
This commit is contained in:
Holger Freyther 2009-01-04 20:15:12 +00:00
parent ca64da984b
commit 5e76ce61ac
1 changed files with 7 additions and 0 deletions

View File

@ -204,12 +204,19 @@ void telnet_send_gsm_48(struct telnet_connection *connection) {
static const char* error[] = {
"48: IMSI not found\n",
"48: No channel allocated for IMSI\n" };
int ret;
struct gsm_bts *bts = &connection->network->bts[connection->bts];
struct gsm_lchan *lchan = find_channel(bts, connection->imsi, error, connection->fd.fd);
if (!lchan)
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 gsm48_hdr *gh;
int i;