Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
multiline: cri change strpbrk to memchr
Browse files Browse the repository at this point in the history
Signed-off-by: ryanohnemus <[email protected]>
ryanohnemus committed Jan 10, 2025
1 parent 9030e20 commit f12ed54
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/flb_parser_cri.c
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ int flb_parser_cri_do(struct flb_parser *parser,
time_key_len = strlen(time_key);

/* Time */
token_end = strchr(in_buf, CRI_SPACE_DELIM);
token_end = memchr(in_buf, CRI_SPACE_DELIM, in_size);

Check failure

Code scanning / ClusterFuzzLite/CIFuzz

A read or write past the end of a heap buffer. Error

Heap-buffer-overflow
READ 2

/* after we find 'time' field (which is variable length),
* we also check that we have enough room for static size fields
@@ -112,7 +112,10 @@ int flb_parser_cri_do(struct flb_parser *parser,
token_end = token_end + 2; /* indicator + a space */

/* Log */
end_of_line = strpbrk(token_end, "\r\n");
end_of_line = memchr(token_end, '\n', token_end-in_buf);
if (end_of_line == NULL) {
end_of_line = memchr(token_end, '\r', token_end-in_buf);
}
if (end_of_line == NULL || end_of_line-token_end > in_size) {
end_of_line = (char *)in_buf+in_size;
}

0 comments on commit f12ed54

Please sign in to comment.