Skip to content

Commit ad3084e

Browse files
committed
io: Add crash guards
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent 43f756f commit ad3084e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/flb_io.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,17 @@ int flb_io_net_writev(struct flb_connection *connection,
726726
total_length = 0;
727727

728728
for (index = 0 ; index < iovcnt ; index++) {
729+
/* Overflow guard */
730+
if (iov[index].iov_len > SIZE_MAX - total_length) {
731+
errno = EOVERFLOW;
732+
return -1;
733+
}
734+
735+
if (iov[index].iov_len > 0 && iov[index].iov_base == NULL) {
736+
errno = EINVAL;
737+
return -1;
738+
}
739+
729740
total_length += iov[index].iov_len;
730741
}
731742

0 commit comments

Comments
 (0)