Skip to content

Commit

Permalink
Address integer overflow reported by a code analyser
Browse files Browse the repository at this point in the history
The output of /usr/sbin/netstat would have to be larger than 2 GB
for this to abe a menace. Because this seems quite unprobable,
address with an assert() for now.
  • Loading branch information
DimitriPapadopoulos committed Dec 28, 2023
1 parent 2f9ae3d commit 7d8a2ed
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ static int ipv4_get_route(struct rtentry *route)
while (fgets(line, buffer_size - total_bytes_read - 1, fp) != NULL) {
uint32_t bytes_read = strlen(line);

assert(total_bytes_read < UINT32_MAX - bytes_read);
total_bytes_read += bytes_read;

if (bytes_read > 0 && line[bytes_read - 1] != '\n') {
Expand Down

0 comments on commit 7d8a2ed

Please sign in to comment.