Browse code

sigtool/sigtool.c: better error messages (bb#1396)

git-svn: trunk@4802

Tomasz Kojm authored on 2009/02/17 19:38:42
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Tue Feb 17 12:07:37 CET 2009 (tk)
2
+---------------------------------
3
+ * sigtool/sigtool.c: better error messages (bb#1396)
4
+
1 5
 Tue Feb 17 01:36:36 CET 2009 (acab)
2 6
 -----------------------------------
3 7
  * clamd: add --stream option to force streaming even to the localhost
... ...
@@ -1352,10 +1352,17 @@ static int compare(const char *oldpath, const char *newpath, FILE *diff)
1352 1352
     old = fopen(oldpath, "r");
1353 1353
 
1354 1354
     while(fgets(nbuff, sizeof(nbuff), new)) {
1355
+	i = strlen(nbuff);
1356
+	if(i >= 2 && (nbuff[i - 1] == '\r' || (nbuff[i - 1] == '\n' && nbuff[i - 2] == '\r'))) {
1357
+	    mprintf("!compare: New %s file contains lines terminated with CRLF or CR\n", newpath);
1358
+	    if(old)
1359
+		fclose(old);
1360
+	    return -1;
1361
+	}
1355 1362
 	cli_chomp(nbuff);
1356 1363
 #ifdef COMPATIBILITY_LIMIT
1357 1364
 	if(strlen(nbuff) > COMPATIBILITY_LIMIT) {
1358
-	    mprintf("!compare: COMPATIBILITY_LIMIT: Line too long\n");
1365
+	    mprintf("!compare: COMPATIBILITY_LIMIT: Found too long line in new %s\n", newpath);
1359 1366
 	    if(old)
1360 1367
 		fclose(old);
1361 1368
 	    return -1;
... ...
@@ -1608,6 +1615,8 @@ static int diffdirs(const char *old, const char *new, const char *patch)
1608 1608
 
1609 1609
 	    snprintf(path, sizeof(path), "%s/%s", old, dent->d_name);
1610 1610
 	    if(compare(path, dent->d_name, diff) == -1) {
1611
+		if(chdir(cwd) == -1)
1612
+		    mprintf("^diffdirs: Can't chdir to %s\n", cwd);
1611 1613
 		fclose(diff);
1612 1614
 		unlink(patch);
1613 1615
 		closedir(dd);