NULL pointer dereference fixes#687
NULL pointer dereference fixes#687PrivacyIsARight wants to merge 4 commits intovoid-linux:masterfrom
Conversation
|
With the changes applied it now returns:
|
|
Sorry but the commit is umergable, this should be split up into separate commits for each independent change. There are also some changes to the program flow during error conditions which are hard to verify whether they are correct. And please disclose whether you used any tools to assist with this. |
Aren't changes supposed to be squashed? |
No, why should they. |
Oh, I was following from the advice you gave me on void packages repo. For tools I used, ASAN, gcc, gdb, and some others. |
|
I'll try and separate the commits now. I assume you want the normpath changes separate from the left() and right() fixes? @Duncaen |
I kinda want every single change separately. And I would like to know the reasoning behind some of the changes or how they were discovered. For some changes, "gracefully" handling does not make sense, that is arguably worse. |
I assume this is because assert causes it to crash instantly which reveals the issue immediatly. Would die() be a good middleground here? |
|
Yes, errors should be handled like errors, in context where I still would like to know what tool was used to find those specific issues. |
I used claude to identify the issue and then I used the manual tools like ASAN, gdb, etc to craft the poc. |
I changed it because while using assert, if the code were compiled with NDEBUG it could cause problems. |
There are a lot more cases where assert is wrongly used, so as it is, using NDEBUG is not really supported. |
If so, then this could be something you could add to the build instructions. If you want, I can change it back to using assert, and add the EINVAL back in. I just figured that it would be a good change. |
|
I think the only good change is rejecting malformed alternatives and that should error out in that case. |
|
And maybe the changes to The |
|
So revert to EINVAL and assert, and remove the strcmp changes? Is the change to |
|
That's fine, but separate from the other changes. |
e52f3f4 to
fe172a8
Compare
|
These should be the changes we are able to add without issue. |
Fixed off-by-one errors in calloc and malloc calls by adding the required byte for the null terminator.
Added string length guards before strncmp operations to prevent potential buffer over-reads on short paths.
Hardened pointer arithmetic by ensuring strchr results are not NULL before incrementing them.
Replaced assert() with conditional checks to allow the tool to skip malformed entries gracefully instead of crashing.
Improved hashing safety by using sizeof on the destination buffer (xe->sha256) rather than local variables.
Ensured memory integrity by calling free() on local allocations before skipping iterations in the new error paths.
You can test the PoC out with a command like this.