Message ID | 20241029080117.625177-4-jmarchan@redhat.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 7abca57513270b46500f3395596054110be4af55 |
Headers | show |
Series | trace-cmd: fix misc issues found by static analysis | expand |
diff --git a/lib/trace-cmd/trace-output.c b/lib/trace-cmd/trace-output.c index 66e11ddc..8bc9325c 100644 --- a/lib/trace-cmd/trace-output.c +++ b/lib/trace-cmd/trace-output.c @@ -2070,6 +2070,8 @@ __hidden void *trace_get_options(struct tracecmd_output *handle, size_t *len) } offset = do_lseek(&out_handle, 0, SEEK_CUR); + if (offset == (off_t)-1) + goto out; buf = malloc(offset); if (!buf) goto out;
Check that do_lseek doesn't fail before calling malloc() with a -1 argument. This is flagged as an overrun error (CWE-119) by static anaysis because of the call to read() later, but I don't imagine that malloc would succeed. Signed-off-by: Jerome Marchand <jmarchan@redhat.com> --- lib/trace-cmd/trace-output.c | 2 ++ 1 file changed, 2 insertions(+)