martijnvanbrummelen / nwipe

nwipe secure disk eraser
GNU General Public License v2.0
801 stars 86 forks source link

Uninitialized values in pass.c, causing undefined behaviour #563

Closed Knogle closed 8 months ago

Knogle commented 8 months ago

Ahoy.

In Valgrind we encounter a lot of issues and accesses regarding uninitialized values in memory. Almost all of them are related to pass.c


==10289== Conditional jump or move depends on uninitialised value(s)
==10289==    at 0x484E90E: bcmp (vg_replace_strmem.c:1229)
==10289==    by 0x41138B: nwipe_random_verify (pass.c:198)
==10289==    by 0x4160A6: nwipe_runmethod (method.c:961)
==10289==    by 0x417019: nwipe_random (method.c:742)
==10289==    by 0x4E98946: start_thread (pthread_create.c:444)
==10289==    by 0x4F1E873: clone (clone.S:100)

What i have encountered.

Initial issue analysis around line 198 in pass.c // Problem: Possible use of uninitialized memory in memcmp function call.

Solution: Ensure 'b' and 'd' buffers are fully initialized before memcmp call

Unfortunately i wasn't able to properly track down from where b and d originate, and where they are initialized. Maybe we can track that down.

Knogle commented 8 months ago

Adressed in https://github.com/martijnvanbrummelen/nwipe/pull/564