diff options
Diffstat (limited to 'recipes-core/fastjar/fastjar/jartool.patch')
-rw-r--r-- | recipes-core/fastjar/fastjar/jartool.patch | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/recipes-core/fastjar/fastjar/jartool.patch b/recipes-core/fastjar/fastjar/jartool.patch new file mode 100644 index 0000000..bb58b27 --- /dev/null +++ b/recipes-core/fastjar/fastjar/jartool.patch | |||
@@ -0,0 +1,114 @@ | |||
1 | Index: fastjar-0.98/jartool.c | ||
2 | =================================================================== | ||
3 | --- fastjar-0.98.orig/jartool.c 2009-09-07 00:10:47.000000000 +0200 | ||
4 | +++ fastjar-0.98/jartool.c 2011-11-10 13:59:01.320585544 +0100 | ||
5 | @@ -790,6 +790,7 @@ | ||
6 | progname, jarfile); | ||
7 | return 1; | ||
8 | } | ||
9 | + ze->filename[len] = '\0'; | ||
10 | len = UNPACK_UB4(header, CEN_EFLEN); | ||
11 | len += UNPACK_UB4(header, CEN_COMLEN); | ||
12 | if (lseek (fd, len, SEEK_CUR) == -1) | ||
13 | @@ -1257,7 +1258,7 @@ | ||
14 | exit_on_error("write"); | ||
15 | |||
16 | /* write the file name to the zip file */ | ||
17 | - if (1 == write(jfd, fname, file_name_length)) | ||
18 | + if (-1 == write(jfd, fname, file_name_length)) | ||
19 | exit_on_error("write"); | ||
20 | |||
21 | if(verbose){ | ||
22 | @@ -1730,7 +1731,17 @@ | ||
23 | struct stat sbuf; | ||
24 | int depth = 0; | ||
25 | |||
26 | - tmp_buff = malloc(sizeof(char) * strlen((const char *)filename)); | ||
27 | + if(*filename == '/'){ | ||
28 | + fprintf(stderr, "Absolute path names are not allowed.\n"); | ||
29 | + exit(EXIT_FAILURE); | ||
30 | + } | ||
31 | + | ||
32 | + tmp_buff = malloc(strlen((const char *)filename)); | ||
33 | + | ||
34 | + if(tmp_buff == NULL) { | ||
35 | + fprintf(stderr, "Out of memory.\n"); | ||
36 | + exit(EXIT_FAILURE); | ||
37 | + } | ||
38 | |||
39 | for(;;){ | ||
40 | const ub1 *idx = (const unsigned char *)strchr((const char *)start, '/'); | ||
41 | @@ -1738,25 +1749,28 @@ | ||
42 | if(idx == NULL) | ||
43 | break; | ||
44 | else if(idx == start){ | ||
45 | + tmp_buff[idx - filename] = '/'; | ||
46 | start++; | ||
47 | continue; | ||
48 | } | ||
49 | - start = idx + 1; | ||
50 | |||
51 | - strncpy(tmp_buff, (const char *)filename, (idx - filename)); | ||
52 | - tmp_buff[(idx - filename)] = '\0'; | ||
53 | + memcpy(tmp_buff + (start - filename), (const char *)start, (idx - start)); | ||
54 | + tmp_buff[idx - filename] = '\0'; | ||
55 | |||
56 | #ifdef DEBUG | ||
57 | printf("checking the existance of %s\n", tmp_buff); | ||
58 | #endif | ||
59 | - if(strcmp(tmp_buff, "..") == 0){ | ||
60 | + if(idx - start == 2 && memcmp(start, "..", 2) == 0){ | ||
61 | --depth; | ||
62 | if (depth < 0){ | ||
63 | fprintf(stderr, "Traversal to parent directories during unpacking!\n"); | ||
64 | exit(EXIT_FAILURE); | ||
65 | } | ||
66 | - } else if (strcmp(tmp_buff, ".") != 0) | ||
67 | + } else if (idx - start != 1 || *start != '.') | ||
68 | ++depth; | ||
69 | + | ||
70 | + start = idx + 1; | ||
71 | + | ||
72 | if(stat(tmp_buff, &sbuf) < 0){ | ||
73 | if(errno != ENOENT) | ||
74 | exit_on_error("stat"); | ||
75 | @@ -1765,6 +1779,7 @@ | ||
76 | #ifdef DEBUG | ||
77 | printf("Directory exists\n"); | ||
78 | #endif | ||
79 | + tmp_buff[idx - filename] = '/'; | ||
80 | continue; | ||
81 | }else { | ||
82 | fprintf(stderr, "Hmmm.. %s exists but isn't a directory!\n", | ||
83 | @@ -1781,10 +1796,11 @@ | ||
84 | if(verbose && handle) | ||
85 | printf("%10s: %s/\n", "created", tmp_buff); | ||
86 | |||
87 | + tmp_buff[idx - filename] = '/'; | ||
88 | } | ||
89 | |||
90 | /* only a directory */ | ||
91 | - if(strlen((const char *)start) == 0) | ||
92 | + if(*start == '\0') | ||
93 | dir = TRUE; | ||
94 | |||
95 | #ifdef DEBUG | ||
96 | @@ -1792,7 +1808,7 @@ | ||
97 | #endif | ||
98 | |||
99 | /* If the entry was just a directory, don't write to file, etc */ | ||
100 | - if(strlen((const char *)start) == 0) | ||
101 | + if(*start == '\0') | ||
102 | f_fd = -1; | ||
103 | |||
104 | free(tmp_buff); | ||
105 | @@ -1876,7 +1892,8 @@ | ||
106 | exit(EXIT_FAILURE); | ||
107 | } | ||
108 | |||
109 | - close(f_fd); | ||
110 | + if (f_fd != -1) | ||
111 | + close(f_fd); | ||
112 | |||
113 | if(verbose && dir == FALSE && handle) | ||
114 | printf("%10s: %s\n", | ||