vos: do not mix memory allocation methods

ListVLDB mixed memory allocated with xdr_alloc() and memory
allocated with malloc().  This is not safe to do since it is
possible on some platforms for xdr_alloc() to allocated memory
using a method other than the malloc() linked to the vos
executable.

Instead of stealing the xdr_alloc()'d buffer, allocate a new
buffer and copy the contents.

Change-Id: Icdda3d4d0b7c15464fe7f48123f3e0ebed4c2cc5
Reviewed-on: http://gerrit.openafs.org/3600
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
This commit is contained in:
Jeffrey Altman 2010-12-27 19:34:14 -05:00 committed by Jeffrey Altman
parent 8e9fff9ed8
commit 463b045b9f

View File

@ -4601,10 +4601,15 @@ ListVLDB(struct cmd_syndesc *as, void *arock)
*/
else if (centries > 0) {
if (!tarray) {
/* steal away the first bulk entries array */
tarray = (struct uvldbentry *)arrayEntries.ubulkentries_val;
/* malloc the first bulk entries array */
tarraysize = centries * sizeof(struct uvldbentry);
arrayEntries.ubulkentries_val = 0;
tarray = malloc(tarraysize);
if (!tarray) {
fprintf(STDERR,
"Could not allocate enough space for the VLDB entries\n");
goto bypass;
}
memcpy((char*)tarray, arrayEntries.ubulkentries_val, tarraysize);
} else {
/* Grow the tarray to keep the extra entries */
parraysize = (centries * sizeof(struct uvldbentry));