Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docproc: guard against overflow #185

Closed

Conversation

ZoltanFridrich
Copy link
Contributor

Report from static analysis shows a possible overflow. The tainted_data_return is not a problem due to the guard in the loop. But there is no guard against overflow of data_len. I am not sure how relevant this is.

Here is the report:

Error: INTEGER_OVERFLOW (CWE-190):
libkcapi-1.4.0/lib/doc/bin/docproc.c:403: tainted_data_return: Called function "read(pipefd[0], data + data_len, 4096UL)", and a possible return value may be less than zero.
libkcapi-1.4.0/lib/doc/bin/docproc.c:403: assign: Assigning: "ret" = "read(pipefd[0], data + data_len, 4096UL)".
libkcapi-1.4.0/lib/doc/bin/docproc.c:406: overflow: The expression "data_len" is considered to have possibly overflowed.
libkcapi-1.4.0/lib/doc/bin/docproc.c:407: overflow: The expression "data_len + 4096UL" is deemed overflowed because at least one of its arguments has overflowed.
libkcapi-1.4.0/lib/doc/bin/docproc.c:407: overflow_sink: "data_len + 4096UL", which might have underflowed, is passed to "realloc(data, data_len + 4096UL)".
#  405|                                                      4096)) > 0) {
#  406|                                           data_len += (size_t)ret;
#  407|->                                         data = realloc(data, data_len + 4096);
#  408|                                           if (!data) {
#  409|                                                   perror("realloc");

Signed-off-by: Zoltan Fridrich <zfridric@redhat.com>
@ZoltanFridrich
Copy link
Contributor Author

@smuellerDD is this worth fixing?

@smuellerDD
Copy link
Owner

smuellerDD commented May 15, 2024 via email

@smuellerDD
Copy link
Owner

Applied, thanks

@smuellerDD smuellerDD closed this May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants