summarylogtreecommitdiffstats
path: root/030_fix-textextract-crash.patch
blob: 5709d8a67cb821bf17c87f7285e9ab5cc728e0e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Description: fix getopt use in tools
             Removed the home-made special-casing for `--help`. It's
             not needed and wasn't interacting right with `getopt`.
Author: Jonas Jensen <jbj@knef.dk>
Bug-Debian: http://bugs.debian.org/716387
Last-Update: 2018-12-02
Index: magicrescue/tools/safecat.c
===================================================================
--- magicrescue.orig/tools/safecat.c
+++ magicrescue/tools/safecat.c
@@ -72,7 +72,7 @@ int main(int argc, char **argv)
 	}
     }
 
-    if (argc - optind != 1 || strcmp(argv[optind], "--help") == 0) {
+    if (argc - optind != 1) {
 	usage();
 	return 1;
     }
Index: magicrescue/tools/textextract.c
===================================================================
--- magicrescue.orig/tools/textextract.c
+++ magicrescue/tools/textextract.c
@@ -317,11 +317,6 @@ int main(int argc, char **argv)
     
     int c, outfd;
 
-    if (argc < 2 || strcmp(argv[1], "--help") == 0) {
-	usage();
-	return 1;
-    }
-
     while ((c = getopt(argc, argv, "M:s:b:l:r:")) >= 0) {
 	switch (c) {
 	case 'M':
@@ -351,6 +346,11 @@ int main(int argc, char **argv)
 	}
     }
 
+    if (argc - optind != 1) {
+	usage();
+	return 1;
+    }
+
     if (strcmp(argv[optind], "-") == 0) {
 	outfd = 1;
     } else if ((outfd =