r183 - in mdadm/trunk/debian: . patches

madduck at users.alioth.debian.org madduck at users.alioth.debian.org
Thu Sep 21 13:25:53 UTC 2006


Author: madduck
Date: 2006-09-21 13:25:53 +0000 (Thu, 21 Sep 2006)
New Revision: 183

Modified:
   mdadm/trunk/debian/changelog
   mdadm/trunk/debian/patches/50-superblock-partition-limit.dpatch
Log:
Reworked the parsing of /proc/partitions and spotted a mean segfault
     (closes: #388355).


Modified: mdadm/trunk/debian/changelog
===================================================================
--- mdadm/trunk/debian/changelog	2006-09-20 17:44:15 UTC (rev 182)
+++ mdadm/trunk/debian/changelog	2006-09-21 13:25:53 UTC (rev 183)
@@ -1,3 +1,12 @@
+mdadm (2.5.3.git200608202239-6) unstable; urgency=high
+
+  * Bumping urgency to high because previous version has been in unstable for
+    three days and this one really only fixes a stupid segfault:
+  * Reworked the parsing of /proc/partitions and spotted a mean segfault
+    (closes: #388355).
+
+ -- martin f. krafft <madduck at debian.org>  Thu, 21 Sep 2006 15:25:21 +0200
+
 mdadm (2.5.3.git200608202239-5) unstable; urgency=medium
 
   * Keeping medium urgency due to RC bug.

Modified: mdadm/trunk/debian/patches/50-superblock-partition-limit.dpatch
===================================================================
--- mdadm/trunk/debian/patches/50-superblock-partition-limit.dpatch	2006-09-20 17:44:15 UTC (rev 182)
+++ mdadm/trunk/debian/patches/50-superblock-partition-limit.dpatch	2006-09-21 13:25:53 UTC (rev 183)
@@ -6,9 +6,33 @@
 
 @DPATCH@
 diff -urNad mdadm.git~/config.c mdadm.git/config.c
---- mdadm.git~/config.c	2006-09-17 19:06:01.000000000 +0200
-+++ mdadm.git/config.c	2006-09-17 19:06:36.000000000 +0200
-@@ -222,28 +222,82 @@
+--- mdadm.git~/config.c	2006-09-20 17:44:25.892724113 +0200
++++ mdadm.git/config.c	2006-09-20 17:46:43.775794421 +0200
+@@ -219,35 +219,116 @@
+     char *name;
+ } *cdevlist = NULL;
+ 
++char* skipblanks(char* buf)
++{
++  if (!buf) return buf;
++  while (*buf != '\0' && isblank(*buf)) ++buf;
++  return buf;
++}
++
++char* skipnonblanks(char* buf)
++{
++  if (!buf) return buf;
++  while (*buf != '\0' && !isblank(*buf)) ++buf;
++  return buf;
++}
++
++char* skipdigits(char* buf)
++{
++  if (!buf) return buf;
++  while (*buf != '\0' && isdigit(*buf)) ++buf;
++  return buf;
++}
++
  mddev_dev_t load_partitions(void)
  {
  	FILE *f = fopen("/proc/partitions", "r");
@@ -24,7 +48,7 @@
 -		int major, minor;
 -		char *name, *mp;
 +	while (!feof(f) && fgets(buf, 1024, f)) {
-+		unsigned long major, minor, iter;
++		unsigned long major, minor;
 +		char *name, *kernel_name, *mp, *ptr;
  		mddev_dev_t d;
  
@@ -41,6 +65,7 @@
 +     */
 +		ptr = strchr(buf, '\n');
 +		if (ptr) *ptr = '\0';
++    fprintf(stderr, "Line: %s\n", buf);
 +
 +    /*
 +     * Extract the major and minor numbers and obtain the device node name.
@@ -50,8 +75,13 @@
  		major = strtoul(buf, &mp, 10);
 -		if (mp == buf || *mp != ' ') 
 -			continue;
+-		minor = strtoul(mp, NULL, 10);
 +		if (mp == buf || *mp != ' ') continue;
- 		minor = strtoul(mp, NULL, 10);
++    mp = skipblanks(mp);
++    fprintf(stderr, "mp1='%c'\n", (unsigned char)*mp);
++		minor = strtoul(mp, &mp, 10);
++    mp = skipblanks(mp);
++    fprintf(stderr, "mp2='%c'\n", (unsigned char)*mp);
  
  		name = map_dev(major, minor, 1);
 -		if (!name)
@@ -59,22 +89,22 @@
 +		if (!name) continue;
 +
 +    /* 
-+     * Get the kernel name, which is the forth of the space-separated fields.
++     * mp now points at the third field, which is digits only. We thus skip
++     * all spaces and digits to reach the forth field.
 +     */
-+    mp = buf;
-+    while (isspace(*(++mp)));
-+    for (iter = 0; iter < 3; ++iter) {
-+      while (!isspace(*(++mp)));
-+      while (isspace(*(++mp)));
-+    }
++    mp = skipdigits(mp);
++    fprintf(stderr, "mp3='%c'\n", (unsigned char)*mp);
++    mp = skipblanks(mp);
++    fprintf(stderr, "mp4='%c'\n", (unsigned char)*mp);
 +
 +    /* 
 +     * Now the cursor is at the beginning to the kernel name, so we point
 +     * there and terminate the string on the first space character.
 +     */
 +    kernel_name = mp;
-+    while (!isspace(*(++mp)));
++    mp = skipnonblanks(mp);
 +    *mp = '\0';
++    fprintf(stderr, "kernel_name: %s\n", kernel_name);
 +
 +		/* 
 +		 * Check if this could be a partition of the previous device
@@ -102,3 +132,8 @@
  		d = malloc(sizeof(*d));
  		d->devname = strdup(name);
  		d->next = rv;
+ 		d->used = 0;
++    fprintf(stderr, "rv=%p, d=%p, d->next=%p, d->devname=%s\n", rv, d, d->next, d->devname);
+ 		rv = d;
+ 	}
+ 	fclose(f);




More information about the pkg-mdadm-commits mailing list