-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[libc] Expand usage of libc null checks. #116262
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
Merged
lntue
merged 59 commits into
llvm:main
from
AlyElashram:Expand-usage-of-libc-null-checks
Jun 4, 2025
Merged
Changes from all commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
909e318
Add NullChecks to fflush.cpp
AlyElashram c95c335
Add NullChecks to fopen.cpp
AlyElashram 67e7cf1
Add NullChecks to fprintf.cpp
AlyElashram 1d75d8b
Add NullChecks to fscanf.cpp
AlyElashram 009712f
Add NullChecks to vprintf.cpp
AlyElashram 7ea30f2
Add NullChecks to memchr.cpp
AlyElashram f60019c
Add NullChecks to memcmp.cpp
AlyElashram 664e3ba
Add NullChecks to memcpy.cpp
AlyElashram 1786835
Add NullChecks to memmove.cpp
AlyElashram b934143
Add NullChecks to mempcpy.cpp
AlyElashram 56a9bda
Add NullChecks to memrchr.cpp
AlyElashram 1b9902a
Add NullChecks to memset.cpp
AlyElashram 199f029
Add NullChecks to rindex.cpp
AlyElashram 43cd69a
Add NullChecks to stpncpy.cpp
AlyElashram f9bb084
Add NullChecks to strcat.cpp
AlyElashram dbec9c4
Add NullChecks to strcoll.cpp and strcoll_l.cpp
AlyElashram 4baf7e2
Add NullChecks to strcpy and strncpy
AlyElashram d9b3681
Add NullChecks to strsep.cpp
AlyElashram dafd61a
Add NullChecks to strspn.cpp
AlyElashram 06da963
Revert "Add NullChecks to vprintf.cpp"
AlyElashram c936096
Revert "Add NullChecks to fscanf.cpp"
AlyElashram b6dd178
Revert "Add NullChecks to fprintf.cpp"
AlyElashram ccaec3f
Revert "Add NullChecks to fopen.cpp"
AlyElashram 9f86f3f
Revert "Add NullChecks to fflush.cpp"
AlyElashram 35e0367
Modify NullChecks to cast pointers as it will fail dereferencing a nu…
AlyElashram 1d704e2
Modify Unit Tests to include crashing on nullptrs
AlyElashram 7253320
Formatting
AlyElashram f842fa9
Patch up memcmp test
AlyElashram c2ed5dd
Patch up memcpy test
AlyElashram 6cdc4c4
Only USe unit tests for memcmp test suites
AlyElashram d52bad8
Add Unit Tests to remaining suites
AlyElashram 19ab698
Formatting
AlyElashram 778adf9
add if def guards for linux to all AssertDeath tests
AlyElashram a600ecd
Add Missing extra lines at the eof
AlyElashram f88e326
Crash on nullptr in string_length
AlyElashram 15896aa
Remove pattern of making pointer copies
AlyElashram 01ccacd
Convert Seg fault to SIGILL
AlyElashram 7335aac
Convert Seg fault to SIGILL
AlyElashram 41d9a4f
Trap on both pointers in strsep.cpp
AlyElashram de748e5
Only Crash when count is greater than 0
AlyElashram 82e5418
Formatting
AlyElashram 9baa777
Remove Crashing on null ptr in util function
AlyElashram bccdf5b
Remove > 0 check (tautology)
AlyElashram 5aa2a30
count instead of c
alyyelashram d05ef6e
Move inline_strstr.h crash to entrypoints
alyyelashram 961cbce
Change all tests to use ifdef guards
alyyelashram 644770d
Patch Tests' cmake
AlyElashram ee9e873
Patch all tests to use the correct ifdef guards and change the signal…
AlyElashram e6a336f
Update tests to match any signal
AlyElashram b380370
Update memmove to pass a non zero count
AlyElashram 3fab6bd
Missing braxe in memcpy_test.cpp
AlyElashram b72022b
Remove unit test only flag.
AlyElashram cee9a32
Update endif comment
AlyElashram 914b4bf
remove unit test only flag from add_libc_tests
AlyElashram 6edc893
Add count checks for memrchr,memset and stpncpy
AlyElashram 8340c41
follow code convention with braces
AlyElashram 50ea5bc
Mass update comments
AlyElashram 5e85e39
Change Mempcpy to be consistent with memcpy
AlyElashram 7c8a0a6
Update mempcpy_test.cpp to have n > 0
AlyElashram File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a count check here , for consistency with memcpy and also since memcpy and mempcpy are well behaved at n = 0
@lntue