]> git.ipfire.org Git - ipfire-2.x.git/blob - src/patches/SuSE10.2/stage2-wildcard-zerowidth.diff
Update des GFXBoot-Patches für GRUB aus SuSE 10.2 v8.
[ipfire-2.x.git] / src / patches / SuSE10.2 / stage2-wildcard-zerowidth.diff
1 Index: grub-0.95/stage2/stage2.c
2 ===================================================================
3 --- grub-0.95.orig/stage2/stage2.c
4 +++ grub-0.95/stage2/stage2.c
5 @@ -1264,11 +1264,11 @@ wildcard_handler(char *name)
6 p = name + grub_strlen (name) - grub_strlen (wildcard_suffix);
7 /* [n .. p) is the part matching the asterisk */
8
9 - if (p <= n || grub_strcmp (p, wildcard_suffix) != 0)
10 - return; /* zero-length match or suffix mismatch */
11 + if (p < n || grub_strcmp (p, wildcard_suffix) != 0)
12 + return; /* suffix mismatch */
13
14 /* store this match */
15 - if (p - n + 2 > sizeof (wildcard_matches) -
16 + if (p - n + 1 > sizeof (wildcard_matches) -
17 (end_wildcard_matches - wildcard_matches))
18 return; /* out of space */
19 while (n < p)
20 @@ -1279,7 +1279,7 @@ wildcard_handler(char *name)
21 /* Wildcard expand the GLOB argument. Return NULL upon failure, or
22 a list of 0-terminated expansions, terminated by a zero-length string. */
23 char *
24 -wildcard (char *glob)
25 +wildcard (char *glob, int *len)
26 {
27 char path[128], *p;
28 int ret;
29 @@ -1324,25 +1324,25 @@ wildcard (char *glob)
30 wildcard_prefix[grub_strlen (wildcard_prefix)] = '*';
31 if (!ret)
32 return NULL;
33 - *end_wildcard_matches++ = 0;
34 + *len = end_wildcard_matches - wildcard_matches;
35 return wildcard_matches;
36 }
37
38 #define skip(str) ((str) + grub_strlen (str) + 1)
39
40 -static void inplace_sort (char *str);
41 +static void inplace_sort (char *str, int len);
42
43 static void
44 -inplace_sort (char *str)
45 +inplace_sort (char *str, int len)
46 {
47 int m, n = 0;
48 - char *s, *t, *x;
49 + char *s, *t;
50
51 - for (s = str; *s; s = skip (s))
52 - n++;
53 -
54 /* we use x as temporary storage */
55 - x = s + 1;
56 + char *x = str + len;
57 +
58 + for (s = str; s < x; s = skip (s))
59 + n++;
60
61 for (; n >= 2; n--)
62 {
63 @@ -1368,6 +1368,8 @@ inplace_sort (char *str)
64 }
65 }
66
67 +#undef skip
68 +
69 static int this_config_len (const char *config);
70 static int
71 this_config_len (const char *config)
72 @@ -1468,16 +1470,16 @@ cmain (void)
73 }
74 if (*w == 0 && (*c == ' ' || *c == '\t' || *c == '='))
75 {
76 - int len;
77 + int len, wlen;
78
79 /* This is a wildcard command. Advance to the argument. */
80 while (*c == ' ' || *c == '\t' || *c == '=')
81 c++;
82
83 /* Expand wildcard entry. */
84 - w = wildcard (c);
85 + w = wildcard (c, &wlen);
86 if (w)
87 - inplace_sort (w);
88 + inplace_sort (w, wlen);
89
90 /* Remove the wildcard command from the command section;
91 it has no meaning beyond the wildcard expansion just
92 @@ -1487,7 +1489,7 @@ cmain (void)
93 config_len - (command - config_entries));
94 config_len -= len;
95
96 - while (w && *w)
97 + while (w && wlen)
98 {
99 /* Insert expansion before the wildcard entry in the
100 list of entry names. */
101 @@ -1511,6 +1513,7 @@ cmain (void)
102 config_len += len;
103
104 num_entries++;
105 + wlen -= grub_strlen (w) + 1;
106 w += grub_strlen (w) + 1;
107 }
108
109 Index: grub-0.95/stage2/shared.h
110 ===================================================================
111 --- grub-0.95.orig/stage2/shared.h
112 +++ grub-0.95/stage2/shared.h
113 @@ -1012,7 +1012,7 @@ void grub_close (void);
114 int dir (char *dirname, void (*handle)(char *));
115
116 /* Wildcard expand the last pathname component of GLOB. */
117 -char *wildcard (char *glob);
118 +char *wildcard (char *glob, int *len);
119
120 int set_bootdev (int hdbias);
121