Skip to content

Commit c6dcef4

Browse files
Work around Coverity false positive
CID 456638 Overflowed integer argument (INTEGER_OVERFLOW) `buffer_size - total_bytes_read - 1UL`, which might have underflowed, is passed to `read()`.
1 parent 8b90c50 commit c6dcef4

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/ipv4.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include <stdlib.h>
3737
#include <stdint.h>
3838
#include <string.h>
39-
#include <assert.h>
4039

4140
#define IPV4_GET_ROUTE_BUFFER_CHUNK_SIZE 65536
4241
#define SHOW_ROUTE_BUFFER_SIZE 128
@@ -179,7 +178,7 @@ static int ipv4_get_route(struct rtentry *route)
179178

180179
while ((bytes_read = read(fd, buffer + total_bytes_read,
181180
buffer_size - total_bytes_read - 1)) > 0) {
182-
assert(SIZE_MAX - total_bytes_read >= bytes_read);
181+
assert(SIZE_MAX - total_bytes_read - 1 >= bytes_read);
183182
total_bytes_read += bytes_read;
184183

185184
if ((buffer_size - total_bytes_read) < 1) {

0 commit comments

Comments
 (0)