[PATCH] Fix name for jm format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

this patch fixes a problem with the name of the jm metaformat.
The ondisk name is 16 chars with leading spaces if the actual name
is shorter and does not have a zero termination.
The current code does correctly extract the name: It assumes implicitly
a zero termination and also includes the spaces in the name.

Matthias

Index: 1.0.0.rc13/lib/format/ataraid/jm.c
===================================================================
--- 1.0.0.rc13.orig/lib/format/ataraid/jm.c
+++ 1.0.0.rc13/lib/format/ataraid/jm.c
@@ -28,10 +28,15 @@ static char *name(struct lib_context *lc
 	size_t len;
 	struct jm *jm = META(rd, jm);
 	char buf[2], *ret, *name = (char *) jm->name;
+	char buf0[JM_NAME_LEN+1] = { '\0' };
+	size_t i = JM_NAME_LEN-1;
 
-	/* Name always 0 terminated ? */
-	if ((len = strlen(name)) > JM_NAME_LEN)
-		len = JM_NAME_LEN;
+	strncpy(buf0, jm->name, JM_NAME_LEN);
+	while (i!=0 && buf0[i]==' ') {
+		buf0[i]='\0';
+		--i;
+	}
+	len = strlen(buf0);
 
 	len += sizeof(HANDLER) + 2;
 	if (jm->mode == JM_T_RAID01)
_______________________________________________
Ataraid-list mailing list
Ataraid-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/ataraid-list

[Index of Archives]     [Linux RAID]     [Linux Device Mapper]     [Linux IDE]     [Linux SCSI]     [Kernel]     [Linux Books]     [Linux Admin]     [GFS]     [RPM]     [Yosemite Campgrounds]     [AMD 64]

  Powered by Linux