1 |
grobian 08/09/08 08:01:36 |
2 |
|
3 |
Modified: scanmacho.c |
4 |
Log: |
5 |
Implemented etype matching for scanmacho |
6 |
|
7 |
Revision Changes Path |
8 |
1.2 pax-utils/scanmacho.c |
9 |
|
10 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanmacho.c?rev=1.2&view=markup |
11 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanmacho.c?rev=1.2&content-type=text/plain |
12 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/pax-utils/scanmacho.c?r1=1.1&r2=1.2 |
13 |
|
14 |
Index: scanmacho.c |
15 |
=================================================================== |
16 |
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanmacho.c,v |
17 |
retrieving revision 1.1 |
18 |
retrieving revision 1.2 |
19 |
diff -u -r1.1 -r1.2 |
20 |
--- scanmacho.c 8 Sep 2008 07:02:56 -0000 1.1 |
21 |
+++ scanmacho.c 8 Sep 2008 08:01:35 -0000 1.2 |
22 |
@@ -1,7 +1,7 @@ |
23 |
/* |
24 |
* Copyright 2008 Gentoo Foundation |
25 |
* Distributed under the terms of the GNU General Public License v2 |
26 |
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanmacho.c,v 1.1 2008/09/08 07:02:56 grobian Exp $ |
27 |
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanmacho.c,v 1.2 2008/09/08 08:01:35 grobian Exp $ |
28 |
* |
29 |
* based on scanelf by: |
30 |
* Copyright 2003-2007 Ned Ludd - <solar@g.o> |
31 |
@@ -10,7 +10,7 @@ |
32 |
* 2008 Fabian Groffen - <grobian@g.o> |
33 |
*/ |
34 |
|
35 |
-static const char *rcsid = "$Id: scanmacho.c,v 1.1 2008/09/08 07:02:56 grobian Exp $"; |
36 |
+static const char *rcsid = "$Id: scanmacho.c,v 1.2 2008/09/08 08:01:35 grobian Exp $"; |
37 |
const char * const argv0 = "scanmacho"; |
38 |
|
39 |
#include "paxinc.h" |
40 |
@@ -330,7 +330,7 @@ |
41 |
return 0; |
42 |
} |
43 |
|
44 |
-/* scan a single elf */ |
45 |
+/* scan a single Mach-O */ |
46 |
static int scanmacho_fat(const char *filename, int fd, size_t len) |
47 |
{ |
48 |
int ret = 1; |
49 |
@@ -357,24 +357,22 @@ |
50 |
default: |
51 |
break; |
52 |
} |
53 |
- /* TODO: match match_etypes against fobj->mhdr.hdr32.filetype */ |
54 |
-#if 0 |
55 |
if (strlen(match_etypes)) { |
56 |
- char sbuf[126]; |
57 |
- strncpy(sbuf, match_etypes, sizeof(sbuf)); |
58 |
- if (strchr(match_etypes, ',') != NULL) { |
59 |
- char *p; |
60 |
- while ((p = strrchr(sbuf, ',')) != NULL) { |
61 |
- *p = 0; |
62 |
- if (etype_lookup(p+1) == get_etype(elf)) |
63 |
- goto label_ret; |
64 |
+ char sbuf[128]; |
65 |
+ char ftype[32]; |
66 |
+ |
67 |
+ snprintf(sbuf, 128, ",%s,", match_etypes); |
68 |
+ |
69 |
+ walk = fobj; |
70 |
+ do { |
71 |
+ snprintf(ftype, 32, ",%s,", get_machomhtype(walk)); |
72 |
+ if (strstr(sbuf, ftype) != NULL) { |
73 |
+ ret = scanmacho_fatobj(walk); |
74 |
} |
75 |
- } |
76 |
- if (etype_lookup(sbuf) != get_etype(elf)) |
77 |
- goto label_done; |
78 |
+ } while (walk->next != NULL && (walk = walk->next)); |
79 |
+ goto label_done; |
80 |
} |
81 |
-label_ret: |
82 |
-#endif |
83 |
+ |
84 |
walk = fobj; |
85 |
do { |
86 |
ret = scanmacho_fatobj(walk); |
87 |
@@ -651,12 +649,6 @@ |
88 |
break; |
89 |
case 'M': |
90 |
match_bits = atoi(optarg); |
91 |
- if (match_bits == 0) { |
92 |
- if (strcmp(optarg, "ELFCLASS32") == 0) |
93 |
- match_bits = 32; |
94 |
- if (strcmp(optarg, "ELFCLASS64") == 0) |
95 |
- match_bits = 64; |
96 |
- } |
97 |
break; |
98 |
case 'O': |
99 |
if (sscanf(optarg, "%o", &match_perms) == (-1)) |