Skip to content

Commit 0fd77c4

Browse files
committed
Bound check data size received
1 parent 2886874 commit 0fd77c4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/dhcp6relay/src/relay.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,8 @@ void relay_client(int sock, const uint8_t *msg, int32_t len, const ip6_hdr *ip_h
481481
* @return none
482482
*/
483483
void relay_relay_reply(int sock, const uint8_t *msg, int32_t len, relay_config *config) {
484-
static uint8_t buffer[4096];
484+
const int BUFF_SIZE = 4096;
485+
static uint8_t buffer[BUFF_SIZE];
485486
uint8_t type = 0;
486487
struct sockaddr_in6 target_addr;
487488
auto current_buffer_position = buffer;
@@ -493,7 +494,7 @@ void relay_client(int sock, const uint8_t *msg, int32_t len, const ip6_hdr *ip_h
493494
auto position = current_position + sizeof(struct dhcpv6_option);
494495
auto dhcpv6msg = parse_dhcpv6_hdr(position);
495496

496-
while ((current_position - msg) < len) {
497+
while ((current_position - msg) < len && len < BUFF_SIZE) {
497498
auto option = parse_dhcpv6_opt(current_position, &tmp);
498499
current_position = tmp;
499500
if (current_position - msg > len) {

0 commit comments

Comments
 (0)