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>
*/
else if (centries > 0) {
if (!tarray) {
- /* steal away the first bulk entries array */
- tarray = (struct uvldbentry *)arrayEntries.ubulkentries_val;
- tarraysize = centries * sizeof(struct uvldbentry);
- arrayEntries.ubulkentries_val = 0;
+ /* malloc the first bulk entries array */
+ tarraysize = centries * sizeof(struct uvldbentry);
+ 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));