[Pvfs2-cvs] commit by pcarns in pvfs2-1/src/io/description: pint-distribution.c

CVS commit program cvs at parl.clemson.edu
Thu May 29 13:00:39 EDT 2008


Update of /projects/cvsroot/pvfs2-1/src/io/description
In directory parlweb1:/tmp/cvs-serv19321

Modified Files:
	pint-distribution.c 
Log Message:
Fix small memory corruption if user specifies a particular distribution in 
server.conf.  Distribution registration may round up the name_size to something larger than the length of the string allocated by dotconf.


Index: pint-distribution.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/io/description/pint-distribution.c,v
diff -p -u -r1.23 -r1.24
--- pint-distribution.c	17 Sep 2006 19:11:13 -0000	1.23
+++ pint-distribution.c	29 May 2008 17:00:38 -0000	1.24
@@ -7,6 +7,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <assert.h>
 
 #define __PINT_REQPROTO_ENCODE_FUNCS_C
 #include "pvfs2-types.h"
@@ -95,8 +96,13 @@ PINT_dist *PINT_dist_create(const char *
 	      = (char *) new_dist + roundup8(sizeof(*new_dist));
 	    new_dist->params
 	      = (void *)(new_dist->dist_name + roundup8(new_dist->name_size));
+            /* after lookup there must be enough room to hold name */
+            assert(old_dist.name_size >= (strlen(old_dist.dist_name) + 1));
+            /* copy using length of string passed in by caller
+             * rather than rounded up name_size used for distribution packing
+             */
 	    memcpy(new_dist->dist_name, old_dist.dist_name,
-	      old_dist.name_size);
+	      (strlen(old_dist.dist_name) + 1));
 	    memcpy(new_dist->params, old_dist.params, old_dist.param_size);
 	    /* leave methods pointing to same static functions */
 	}



More information about the Pvfs2-cvs mailing list