Blame SOURCES/0220-RHBZ-1448223-fix-kpartx.patch

4728c8
---
4728c8
 kpartx/kpartx.c |   23 ++++++++++++++++-------
4728c8
 1 file changed, 16 insertions(+), 7 deletions(-)
4728c8
4728c8
Index: multipath-tools-130222/kpartx/kpartx.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/kpartx/kpartx.c
4728c8
+++ multipath-tools-130222/kpartx/kpartx.c
4728c8
@@ -114,10 +114,13 @@ set_delimiter (char * device, char * del
4728c8
 {
4728c8
 	char * p = device;
4728c8
 
4728c8
-	while (*(p++) != 0x0)
4728c8
+	if (*p == 0x0)
4728c8
+		return;
4728c8
+
4728c8
+	while (*(++p) != 0x0)
4728c8
 		continue;
4728c8
 
4728c8
-	if (isdigit(*(p - 2)))
4728c8
+	if (isdigit(*(p - 1)))
4728c8
 		*delimiter = 'p';
4728c8
 }
4728c8
 
4728c8
@@ -136,15 +139,17 @@ strip_slash (char * device)
4728c8
 static int
4728c8
 find_devname_offset (char * device)
4728c8
 {
4728c8
-	char *p, *q = NULL;
4728c8
+	char *p, *q;
4728c8
 
4728c8
-	p = device;
4728c8
+	q = p = device;
4728c8
 
4728c8
-	while (*p++)
4728c8
+	while (*p) {
4728c8
 		if (*p == '/')
4728c8
-			q = p;
4728c8
+			q = p + 1;
4728c8
+		p++;
4728c8
+	}
4728c8
 
4728c8
-	return (int)(q - device) + 1;
4728c8
+	return (int)(q - device);
4728c8
 }
4728c8
 
4728c8
 static char *
4728c8
@@ -343,6 +348,10 @@ main(int argc, char **argv){
4728c8
 		}
4728c8
 		device = loopdev;
4728c8
 	}
4728c8
+	else if (!S_ISBLK(buf.st_mode)) {
4728c8
+		fprintf(stderr, "invalid device: %s\n", device);
4728c8
+		exit(1);
4728c8
+	}
4728c8
 
4728c8
 	off = find_devname_offset(device);
4728c8