You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have identified these issues through static auditing and would like to provide a brief report. Considering this is a test tool, the impact of not fixing them may be minimal, but they are still worth noting:
The missing fclose() does not actually leak anything, because tst_brkm_() ends up calling exit(). The return in the code is there only for the case where a test is in the cleanup() callback, where we do want to finish the cleanup even if error has happened and tst_brkm_() skips calling exit() in that case. However cleanup() is called at the end of the test and the test exits once cleanup() is finished. In summary in this case the static analysis is not smart enough to understand the complexity of the code.
The buffer overflow in tst_tmpdir.c should be fixed. I suppose that the best option would be passing dirfd to the rmobj() and use openat() instead of open() there.
pevik
changed the title
Some bug reports.
The buffer overflow in tst_tmpdir.c
May 16, 2025
pevik
changed the title
The buffer overflow in tst_tmpdir.c
Fix buffer overflow in tst_tmpdir.c
May 16, 2025
I have identified these issues through static auditing and would like to provide a brief report. Considering this is a test tool, the impact of not fixing them may be minimal, but they are still worth noting:
1.Using sprintf without length checking may lead to buffer overflow.
https://github.com/linux-test-project/ltp/blob/master/lib/tst_tmpdir.c#L186
2.Missing fclose(f) in the return path causes resource leaks.
https://github.com/linux-test-project/ltp/blob/master/lib/safe_file_ops.c#L146
https://github.com/linux-test-project/ltp/blob/master/lib/safe_file_ops.c#L153
https://github.com/linux-test-project/ltp/blob/master/lib/safe_file_ops.c#L274
The text was updated successfully, but these errors were encountered: