Skip to content

Commit

Permalink
[dhcp_relay] fix data type in dhcp6relay, add protection in packet da…
Browse files Browse the repository at this point in the history
…ta parsing (#9036)
  • Loading branch information
kellyyeh authored and yxieca committed Oct 25, 2022
1 parent 5868b9e commit 7fb8dae
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/dhcp6relay/src/relay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,15 +593,14 @@ void relay_relay_forw(int sock, const uint8_t *msg, int32_t len, const ip6_hdr *
void callback(evutil_socket_t fd, short event, void *arg) {
struct relay_config *config = (struct relay_config *)(arg);
static uint8_t message_buffer[4096];
std::string counterVlan = counter_table;
int32_t len = recv(config->filter, message_buffer, 4096, 0);
if (len <= 0) {
syslog(LOG_WARNING, "recv: Failed to receive data at filter socket: %s\n", strerror(errno));
return;
}

char* ptr = (char *)message_buffer;
const uint8_t *current_position = (uint8_t *)ptr;
const uint8_t *current_position = (uint8_t *)ptr;
const uint8_t *tmp = NULL;
const uint8_t *prev = NULL;

Expand All @@ -623,7 +622,7 @@ void callback(evutil_socket_t fd, short event, void *arg) {
prev = current_position;
}
while (ext_header->ip6e_nxt != IPPROTO_UDP);
}
}

auto udp_header = parse_udp(current_position, &tmp);
current_position = tmp;
Expand Down

0 comments on commit 7fb8dae

Please sign in to comment.