⬢ DragonFlyBSD Kernel Audit
DF-4592 / fix.combined.diff
← back to finding ↓ download raw
--- a/sys/dev/raid/vinum/vinumio.c
+++ b/sys/dev/raid/vinum/vinumio.c
@@ -489,6 +489,8 @@
 		    configend - s,
 		    " sd %s",
 		    vinum_conf.sd[plex->sdnos[j]].name);
+		while (*s)
+		    s++;				    /* find the end */
 	    }
 	    s = sappend("\n", s);
 	}
@@ -514,15 +516,23 @@
 	     */
 	    if (drivename[0] == '\0')
 		drivename = "*invalid*";
-	    ksnprintf(s,
-		configend - s,
-		"sd name %s drive %s plex %s len %llus driveoffset %llus state %s",
-		sd->name,
-		drivename,
-		vinum_conf.plex[sd->plexno].name,
-		(unsigned long long) sd->sectors,
-		(unsigned long long) sd->driveoffset,
-		sd_state(sd->state));
+	    if (sd->plexno >= 0)
+		ksnprintf(s, configend - s,
+		    "sd name %s drive %s plex %s len %llus driveoffset %llus state %s",
+		    sd->name,
+		    drivename,
+		    vinum_conf.plex[sd->plexno].name,
+		    (unsigned long long) sd->sectors,
+		    (unsigned long long) sd->driveoffset,
+		    sd_state(sd->state));
+	    else
+		ksnprintf(s, configend - s,
+		    "sd name %s drive %s len %llus driveoffset %llus state %s",
+		    sd->name,
+		    drivename,
+		    (unsigned long long) sd->sectors,
+		    (unsigned long long) sd->driveoffset,
+		    sd_state(sd->state));
 	    while (*s)
 		s++;					    /* find the end */
 	    if (sd->plexno >= 0)
@@ -689,6 +699,8 @@
     CHECKALLOC(drivelist, "Can't allocate memory");
     error = setjmp(command_fail);			    /* come back here on error */
     if (error) {					    /* longjmped out */
+	Free(drivelist);
+	vinum_conf.flags &= ~VF_READING_CONFIG;
 	return error;
     }
 
@@ -749,6 +761,8 @@
 	    log(LOG_WARNING, "vinum: no drives found\n");
 	else
 	    log(LOG_INFO, "vinum: no additional drives found\n");
+	Free(drivelist);
+	vinum_conf.flags &= ~VF_READING_CONFIG;
 	return ENOENT;
     }
     /*