Skip to content

Commit 274ecb0

Browse files
committed
Validate decom HOSTNAME_LEN before allocating
Signed-off-by: Mark Hannum <mhannum@bloomberg.net>
1 parent 6934ae7 commit 274ecb0

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

net/net_evbuffer.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,16 +1604,16 @@ static int process_decom_hostname(struct event_info *e)
16041604
uint32_t n;
16051605
memcpy(&n, e->rd_buf, sizeof(n));
16061606
e->need = htonl(n);
1607+
if (e->need > HOSTNAME_LEN) {
1608+
hprintf("bad hostname len:%zu\n", e->need);
1609+
return -1;
1610+
}
16071611
return 0;
16081612
}
1609-
if (e->need > HOSTNAME_LEN) {
1610-
hprintf("bad hostname len:%zu\n", e->need);
1611-
} else {
1612-
char host[e->need + 1];
1613-
memcpy(host, e->rd_buf, e->need);
1614-
host[e->need] = 0;
1615-
dispatch_decom(intern(host));
1616-
}
1613+
char host[e->need + 1];
1614+
memcpy(host, e->rd_buf, e->need);
1615+
host[e->need] = 0;
1616+
dispatch_decom(intern(host));
16171617
message_done(e);
16181618
return 0;
16191619
}

0 commit comments

Comments
 (0)