From 463b045b9fe4a412877c2a65f5deafb1442c1bf1 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 27 Dec 2010 19:34:14 -0500 Subject: [PATCH 1/1] 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 Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/volser/vos.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/volser/vos.c b/src/volser/vos.c index d40e2e9..c1bd3b1 100644 --- a/src/volser/vos.c +++ b/src/volser/vos.c @@ -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; - 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)); -- 1.9.4