vos: Don't leak/overflow bulkaddrs
authorSimon Wilkinson <sxw@your-file-system.com>
Tue, 31 May 2011 07:28:51 +0000 (08:28 +0100)
committerDerrick Brashear <shadow@dementia.org>
Wed, 1 Jun 2011 13:13:42 +0000 (06:13 -0700)
commitb6add117ad210665a811213fe17a30fabbda3a3c
treebef3e68ac1685408595adbeaa1cc0c092c3c7bed
parent6af6a6a7cb497d4e255bed7ccf07a5db06d16b91
vos: Don't leak/overflow bulkaddrs

The vos listaddrs command repeatedly reuses a bulkaddrs array. It
zeros it once (without freeing the allocated memory), and then
repeatedly uses it without zeroing in a loop. This means that the XDR
library assumes that a sufficiently large block is already allocated,
doesn't reallocate for the incoming data, or check limits.

This means that if the first call to VL_GetAddrsU returns a set of
addresses smaller than subsequent calls, we'll write past the end
of the array, causing memory corruption.

Fix this by freeing the arrays correctly with each pass of the call.

Change-Id: I540d369c1529ec3574548f42cbd48b6c2b38cebd
Reviewed-on: http://gerrit.openafs.org/4756
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
src/volser/vos.c