hivex: Fix allocations that may move C heap buffer.
authorRichard Jones <rjones@redhat.com>
Tue, 23 Feb 2010 19:08:41 +0000 (19:08 +0000)
committerRichard Jones <rjones@redhat.com>
Tue, 23 Feb 2010 19:17:40 +0000 (19:17 +0000)
commitc9d5cd059c45fd3aa6d16b3ba185d7cb3a08de9e
tree52466a1e19b8bcf04127c35ca8f8890b365ec84b
parentd25b8f213fd4b09d67a94d068ed269f5c1b83954
hivex: Fix allocations that may move C heap buffer.

When heavily extending existing hive files, the malloc-allocated
in-memory copy of the hive may be moved when we reallocate it
(to increase its size).  However we didn't adjust existing
pointers to cope with this, so sometimes you could get a segfault.

This patch fixes the issue by adjusting pointers as necessary
after calling (directly or indirectly) to the allocate_block
function.

With this patch I was able to allocate 10,000's of blocks in
a deeply nested hive structure without any problems being reported
by valgrind.
hivex/hivex.c