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