]> git.itanic.dy.fi Git - rrdd/commit
onewire_parser: Fix double free corruption
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Wed, 26 Oct 2016 17:19:12 +0000 (20:19 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Wed, 26 Oct 2016 17:19:12 +0000 (20:19 +0300)
commita4dd6fcb68d9d763fac0f5774403d61d48bd8a58
tree70b89071f41f0945bd3169950116fa955b85cf5a
parent761f6a7a45bf8882a7694b3a107e35c8a8b868bb
onewire_parser: Fix double free corruption

If there is a failure while reading a sensor value, the pointer
pointing to the destination buffer is undefined. In that case we might
be referring to a previously freed pointer and possibly corrupting
data somewhere else. The heap area might also be already allocated for
something else and freeing it here, making the heap area available to
yet another allocation and further corruptions. This leads to random
and hard to reproduce crashes in various unrelated components.

Fix the issue by initializing the pointer value with NULL. Also avoid
using it when we expect it to be NULL after a failure. Also we are not
passing the NULL pointer to free(), even though calling free on NULL
is bening.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
onewire_parser.c