]> git.tuebingen.mpg.de Git - paraslash.git/commit
server: Avoid use of uninitialized memory.
authorAndre Noll <maan@tuebingen.mpg.de>
Mon, 29 Jan 2018 22:21:11 +0000 (23:21 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 25 Feb 2018 23:07:16 +0000 (00:07 +0100)
commit4c117836f38d3cc661f6271760ee5cab78ada8cf
treeb99f9703723d87b46fb9a524cb212f6913a0e872
parentbde44cf34bd9b334892af6ef4731ecb74b1ab544
server: Avoid use of uninitialized memory.

change_current_mood() receives an errmsg pointer which the callers
expect to be initialized with an error string if (and only if) the
function returns negative.

However, most error paths miss to initialize the pointer which results
in undefined behaviour in the caller which attempts to free(3)
uninitialized memory. The gcc AddressSanitizer and valgrind both
catch this:

gcc:

==14788==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x081af250 in thread T0

valgrind:

==4410== Invalid free() / delete / delete[] / realloc()

The bug was introduced half a year ago when version 2 moods were
introduced in commit 3d3a2f50.
mood.c