[DRBD-cvs] svn commit by phil - r2958 - in branches/drbd-8.0: drbd drbd/linux user - Device names became longer... * Check that we do not ov

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Sat Jun 30 14:09:43 CEST 2007


Author: phil
Date: 2007-06-30 14:09:40 +0200 (Sat, 30 Jun 2007)
New Revision: 2958

Modified:
   branches/drbd-8.0/drbd/drbd_nl.c
   branches/drbd-8.0/drbd/linux/drbd_nl.h
   branches/drbd-8.0/drbd/linux/drbd_tag_magic.h
   branches/drbd-8.0/user/drbdsetup.c
Log:
Device names became longer...
 * Check that we do not overflow string sizes in the tag 
   based netlink protocol.
 * What used to be "/dev/sda1" might be today:
   "/dev/disk/by-id/scsi-SATA_WDC_WD4000YS-01_WD-WCANU2170947-part2".
   Increased the string sizes for backing device and meta device 
   to 128 byte (They where 32 bytes).


Modified: branches/drbd-8.0/drbd/drbd_nl.c
===================================================================
--- branches/drbd-8.0/drbd/drbd_nl.c	2007-06-29 08:46:36 UTC (rev 2957)
+++ branches/drbd-8.0/drbd/drbd_nl.c	2007-06-30 12:09:40 UTC (rev 2958)
@@ -80,7 +80,7 @@
 #define STRING(pn,pr,member,len) \
 	case pn: /* D_ASSERT( tag_type(tag) == TT_STRING ); */ \
 		 arg->member ## _len = dlen; \
-		 memcpy(arg->member,tags,dlen); \
+		 memcpy(arg->member,tags,min_t(size_t,dlen,len)); \
 		 break;
 #include "linux/drbd_nl.h"
 

Modified: branches/drbd-8.0/drbd/linux/drbd_nl.h
===================================================================
--- branches/drbd-8.0/drbd/linux/drbd_nl.h	2007-06-29 08:46:36 UTC (rev 2957)
+++ branches/drbd-8.0/drbd/linux/drbd_nl.h	2007-06-30 12:09:40 UTC (rev 2958)
@@ -19,8 +19,8 @@
 
 PACKET(disk_conf, 3,
 	INT64(		2,	T_MAY_IGNORE,	disk_size)
-	STRING(		3,	T_MANDATORY,	backing_dev,	32)
-	STRING(		4,	T_MANDATORY,	meta_dev,	32)
+	STRING(		3,	T_MANDATORY,	backing_dev,	128)
+	STRING(		4,	T_MANDATORY,	meta_dev,	128)
 	INTEGER(	5,	T_MANDATORY,	meta_dev_idx)
 	INTEGER(	6,	T_MAY_IGNORE,	on_io_error)
 	INTEGER(	7,	T_MAY_IGNORE,	fencing)

Modified: branches/drbd-8.0/drbd/linux/drbd_tag_magic.h
===================================================================
--- branches/drbd-8.0/drbd/linux/drbd_tag_magic.h	2007-06-29 08:46:36 UTC (rev 2957)
+++ branches/drbd-8.0/drbd/linux/drbd_tag_magic.h	2007-06-30 12:09:40 UTC (rev 2958)
@@ -62,15 +62,16 @@
 struct tag {
 	const char* name;
 	int type_n_flags;
+	int max_len;
 };
 
 // declare tag names
 #define PACKET(name, number, fields) fields
 const struct tag tag_descriptions[] = {
-#define INTEGER(pn,pr,member)    [ pn ] = { #member, TT_INTEGER | pr },
-#define INT64(pn,pr,member)      [ pn ] = { #member, TT_INT64   | pr },
-#define BIT(pn,pr,member)        [ pn ] = { #member, TT_BIT     | pr },
-#define STRING(pn,pr,member,len) [ pn ] = { #member, TT_STRING  | pr },
+#define INTEGER(pn,pr,member)    [ pn ] = { #member, TT_INTEGER | pr, sizeof(int)   },
+#define INT64(pn,pr,member)      [ pn ] = { #member, TT_INT64   | pr, sizeof(__u64) },
+#define BIT(pn,pr,member)        [ pn ] = { #member, TT_BIT     | pr, sizeof(int)   },
+#define STRING(pn,pr,member,len) [ pn ] = { #member, TT_STRING  | pr, len           },
 #include "drbd_nl.h"
 };
 

Modified: branches/drbd-8.0/user/drbdsetup.c
===================================================================
--- branches/drbd-8.0/user/drbdsetup.c	2007-06-29 08:46:36 UTC (rev 2957)
+++ branches/drbd-8.0/user/drbdsetup.c	2007-06-30 12:09:40 UTC (rev 2958)
@@ -475,6 +475,15 @@
 
 void add_tag(struct drbd_tag_list *tl, int tag, void *data, int data_len)
 {
+	if(data_len > tag_descriptions[tag_number(tag)].max_len) {
+		fprintf(stderr, "The value for %s may only be %d byte long."
+			" You requested %d.\n",
+			tag_descriptions[tag_number(tag)].name,
+			tag_descriptions[tag_number(tag)].max_len,
+			data_len);
+		exit(20);
+	}
+
 	if( (tl->tag_list_cpos - tl->tag_list_start) + data_len
 	    > tl->tag_size ) {
 		fprintf(stderr, "Tag list size exceeded!\n");



More information about the drbd-cvs mailing list