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
LGTM.com - false positive for cpp/toctou-race-condition #6834
Comments
|
Hi, thanks for raising this. We agree that checking the return value of We'll be keeping an eye on this query, and adding some new test cases in the near future. I suggest that you double check you're happy with the code in |
geoffw0
mentioned this issue
As pointed out in github/codeql#6834, even though there is no issue with the open() call since we check the filedescriptor afterwards, there is a (not problematic) race condition in the old code, where a file could be replaced by a directory or vice versa. Neither of these pose a security risk though. This should fix the LGTM alert.
eldering
mentioned this issue
|
Thanks, that's a correct point that I overlooked. Should be fixed with my PR DOMjudge/domjudge#1249. |
As pointed out in github/codeql#6834, even though there is no issue with the open() call since we check the filedescriptor afterwards, there is a (not problematic) race condition in the old code, where a file could be replaced by a directory or vice versa. Neither of these pose a security risk though. This should fix the LGTM alert.
As pointed out in github/codeql#6834, even though there is no issue with the open() call since we check the filedescriptor afterwards, there is a (not problematic) race condition in the old code, where a file could be replaced by a directory or vice versa. Neither of these pose a security risk though. This should fix the LGTM alert.


eldering commentedOct 8, 2021
Description of the false positive
Even though the code first does a
statand then after that anopenon the same file, it still afterwards checks that theopencall succeeded before operating on the file descriptor. Thus, there is no toctou race condition. I understand that this can be considered an edge case, but still reporting it here for consideration.URL to the alert on the project page on LGTM.com
https://lgtm.com/projects/g/DOMjudge/domjudge/snapshot/66789bbc091123b7a00dc368032b9dbb5f3e0e96/files/judge/evict.c?sort=name&dir=ASC&mode=heatmap#x5362a542144696a7:1
The text was updated successfully, but these errors were encountered: