Contents of /trunk/cpio/patches/cpio-2.9-CVE-2007-4476.patch
Parent Directory | Revision Log
Revision 725 -
(show annotations)
(download)
Mon Dec 22 23:30:56 2008 UTC (15 years, 9 months ago) by niro
File size: 2330 byte(s)
Mon Dec 22 23:30:56 2008 UTC (15 years, 9 months ago) by niro
File size: 2330 byte(s)
-added several cpio fixes
1 | http://bugs.gentoo.org/196978 |
2 | |
3 | --- lib/paxnames.c |
4 | +++ lib/paxnames.c |
5 | @@ -36,15 +36,27 @@ |
6 | return strcmp (name1, name2) == 0; |
7 | } |
8 | |
9 | -/* Return zero if TABLE contains a copy of STRING; otherwise, insert a |
10 | - copy of STRING to TABLE and return 1. */ |
11 | -bool |
12 | -hash_string_insert (Hash_table **table, char const *string) |
13 | +/* Return zero if TABLE contains a LEN-character long prefix of STRING, |
14 | + otherwise, insert a newly allocated copy of this prefix to TABLE and |
15 | + return 1. If RETURN_PREFIX is not NULL, point it to the allocated |
16 | + copy. */ |
17 | +static bool |
18 | +hash_string_insert_prefix (Hash_table **table, char const *string, size_t len, |
19 | + const char **return_prefix) |
20 | { |
21 | Hash_table *t = *table; |
22 | - char *s = xstrdup (string); |
23 | + char *s; |
24 | char *e; |
25 | |
26 | + if (len) |
27 | + { |
28 | + s = xmalloc (len + 1); |
29 | + memcpy (s, string, len); |
30 | + s[len] = 0; |
31 | + } |
32 | + else |
33 | + s = xstrdup (string); |
34 | + |
35 | if (! ((t |
36 | || (*table = t = hash_initialize (0, 0, hash_string_hasher, |
37 | hash_string_compare, 0))) |
38 | @@ -52,7 +64,11 @@ |
39 | xalloc_die (); |
40 | |
41 | if (e == s) |
42 | - return 1; |
43 | + { |
44 | + if (return_prefix) |
45 | + *return_prefix = s; |
46 | + return 1; |
47 | + } |
48 | else |
49 | { |
50 | free (s); |
51 | @@ -60,6 +76,14 @@ |
52 | } |
53 | } |
54 | |
55 | +/* Return zero if TABLE contains a copy of STRING; otherwise, insert a |
56 | + copy of STRING to TABLE and return 1. */ |
57 | +bool |
58 | +hash_string_insert (Hash_table **table, char const *string) |
59 | +{ |
60 | + return hash_string_insert_prefix (table, string, 0, NULL); |
61 | +} |
62 | + |
63 | /* Return 1 if TABLE contains STRING. */ |
64 | bool |
65 | hash_string_lookup (Hash_table const *table, char const *string) |
66 | @@ -88,7 +112,8 @@ |
67 | If ABSOLUTE_NAMES is 0, strip filesystem prefix from the file name. */ |
68 | |
69 | char * |
70 | -safer_name_suffix (char const *file_name, bool link_target, bool absolute_names) |
71 | +safer_name_suffix (char const *file_name, bool link_target, |
72 | + bool absolute_names) |
73 | { |
74 | char const *p; |
75 | |
76 | @@ -121,11 +146,9 @@ |
77 | |
78 | if (prefix_len) |
79 | { |
80 | - char *prefix = alloca (prefix_len + 1); |
81 | - memcpy (prefix, file_name, prefix_len); |
82 | - prefix[prefix_len] = '\0'; |
83 | - |
84 | - if (hash_string_insert (&prefix_table[link_target], prefix)) |
85 | + const char *prefix; |
86 | + if (hash_string_insert_prefix (&prefix_table[link_target], file_name, |
87 | + prefix_len, &prefix)) |
88 | { |
89 | static char const *const diagnostic[] = |
90 | { |