Browse code

sigtool: fix --verify-cdiff

Tomasz Kojm authored on 2011/03/16 23:54:12
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Wed Mar 16 15:53:42 CET 2011 (tk)
2
+---------------------------------
3
+ * sigtool: fix --verify-cdiff
4
+
1 5
 Tue Mar 15 17:56:59 CET 2011 (tk)
2 6
 ---------------------------------
3 7
  * sigtool: allow arbitrary names for --build
... ...
@@ -44,6 +44,7 @@
44 44
 #include <sys/wait.h>
45 45
 #endif
46 46
 #include <dirent.h>
47
+#include <ctype.h>
47 48
 
48 49
 #ifdef HAVE_TERMIOS_H
49 50
 #include <termios.h>
... ...
@@ -1475,15 +1476,31 @@ static int vbadump(const struct optstruct *opts)
1475 1475
     return 0;
1476 1476
 }
1477 1477
 
1478
-static int comparesha(const char *dbname)
1478
+static int comparesha(const char *diff)
1479 1479
 {
1480
-	char info[32], buff[FILEBUFF], *sha;
1480
+	char info[32], buff[FILEBUFF], *sha, *pt, *name;
1481 1481
 	const char *tokens[3];
1482 1482
 	FILE *fh;
1483 1483
 	int ret = 0, tokens_count;
1484 1484
 
1485
+    name = strdup(diff);
1486
+    if(!name) {
1487
+	mprintf("!verifydiff: strdup() failed\n");
1488
+	return -1;
1489
+    }
1490
+    if(!(pt = strrchr(name, '-')) || !isdigit(pt[1])) {
1491
+	mprintf("!verifydiff: Invalid diff name\n");
1492
+	free(name);
1493
+	return -1;
1494
+    }
1495
+    *pt = 0;
1496
+    if((pt = strrchr(name, *PATHSEP)))
1497
+	pt++;
1498
+    else
1499
+	pt = name;
1485 1500
 
1486
-    snprintf(info, sizeof(info), "%s.info", getdbname(dbname, buff, 32));
1501
+    snprintf(info, sizeof(info), "%s.info", pt);
1502
+    free(name);
1487 1503
 
1488 1504
     if(!(fh = fopen(info, "rb"))) {
1489 1505
 	mprintf("!verifydiff: Can't open %s\n", info);
... ...
@@ -1524,7 +1541,6 @@ static int comparesha(const char *dbname)
1524 1524
     return ret;
1525 1525
 }
1526 1526
 
1527
-
1528 1527
 static int rundiff(const struct optstruct *opts)
1529 1528
 {
1530 1529
 	int fd, ret;