thesourcerer8 / hddsuperclone

HDDSuperClone, HDDSuperTool
GNU General Public License v2.0
394 stars 32 forks source link

Enable Asan and UBsan, fix serveral memory errors #10

Closed SomeCrazyGuy closed 2 years ago

SomeCrazyGuy commented 2 years ago

There are a lot of out-of-bounds array and heap accesses in the codebase, just getting the build to complete with address sanitizer enabled required quite a few changes. Most hddsupertool buffers were using C99 VLAs that were too small for the null terminator. As of now the default build enables AddressSanitizer and UndefinedBehaviorSanitizer. I will continue testing functionality and patching issues as they arise, but it might be several more patches before everything is verified working correctly.

There is a reason optimizations have been disabled (-O0) in the makefile, there are probably years of subtle memory bugs and undefined behaviors that have plagued the codebase. This patch will be the first step towards fixing them.

thesourcerer8 commented 2 years ago

Nice cleanup, thanks a lot for that!