diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-05-02 13:21:24 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-05-02 13:21:24 +0000 |
commit | 32dcc53b7162406148203b8222c3f5c5056f70f2 (patch) | |
tree | dcae696c5a80b3f5b51e4926d2e985a2dfcdb21c /util-linux/mdev.c | |
parent | 6da9b00f4fb54b3deba1c2636d69950fdbcc0d67 (diff) | |
download | busybox-w32-32dcc53b7162406148203b8222c3f5c5056f70f2.tar.gz busybox-w32-32dcc53b7162406148203b8222c3f5c5056f70f2.tar.bz2 busybox-w32-32dcc53b7162406148203b8222c3f5c5056f70f2.zip |
mdev: fix a bug where we were eating argv[0] of helper
Diffstat (limited to 'util-linux/mdev.c')
-rw-r--r-- | util-linux/mdev.c | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/util-linux/mdev.c b/util-linux/mdev.c index 9d37b6c90..5e1cd36bb 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c | |||
@@ -156,43 +156,45 @@ static void make_device(char *path, int delete) | |||
156 | mode = strtoul(val, NULL, 8); | 156 | mode = strtoul(val, NULL, 8); |
157 | 157 | ||
158 | /* 4th field (opt): >alias */ | 158 | /* 4th field (opt): >alias */ |
159 | if (ENABLE_FEATURE_MDEV_RENAME) { | 159 | #if ENABLE_FEATURE_MDEV_RENAME |
160 | if (!next) | 160 | if (!next) |
161 | break; | 161 | break; |
162 | if (*next == '>') { | ||
163 | #if ENABLE_FEATURE_MDEV_RENAME_REGEXP | ||
164 | char *s, *p; | ||
165 | unsigned i, n; | ||
166 | |||
162 | val = next; | 167 | val = next; |
163 | next = next_field(val); | 168 | next = next_field(val); |
164 | if (*val == '>') { | 169 | /* substitute %1..9 with off[1..9], if any */ |
165 | #if ENABLE_FEATURE_MDEV_RENAME_REGEXP | 170 | n = 0; |
166 | /* substitute %1..9 with off[1..9], if any */ | 171 | s = val; |
167 | char *s, *p; | 172 | while (*s && *s++ == '%') |
168 | unsigned i, n; | 173 | n++; |
169 | 174 | ||
170 | n = 0; | 175 | p = alias = xzalloc(strlen(val) + n * strlen(device_name)); |
171 | s = val; | 176 | s = val + 1; |
172 | while (*s && *s++ == '%') | 177 | while (*s) { |
173 | n++; | 178 | *p = *s; |
174 | 179 | if ('%' == *s) { | |
175 | p = alias = xzalloc(strlen(val) + n * strlen(device_name)); | 180 | i = (s[1] - '0'); |
176 | s = val + 1; | 181 | if (i <= 9 && off[i].rm_so >= 0) { |
177 | while (*s) { | 182 | n = off[i].rm_eo - off[i].rm_so; |
178 | *p = *s; | 183 | strncpy(p, device_name + off[i].rm_so, n); |
179 | if ('%' == *s) { | 184 | p += n - 1; |
180 | i = (s[1] - '0'); | 185 | s++; |
181 | if (i <= 9 && off[i].rm_so >= 0) { | ||
182 | n = off[i].rm_eo - off[i].rm_so; | ||
183 | strncpy(p, device_name + off[i].rm_so, n); | ||
184 | p += n - 1; | ||
185 | s++; | ||
186 | } | ||
187 | } | 186 | } |
188 | p++; | ||
189 | s++; | ||
190 | } | 187 | } |
188 | p++; | ||
189 | s++; | ||
190 | } | ||
191 | #else | 191 | #else |
192 | alias = xstrdup(val + 1); | 192 | val = next; |
193 | next = next_field(val); | ||
194 | alias = xstrdup(val + 1); | ||
193 | #endif | 195 | #endif |
194 | } | ||
195 | } | 196 | } |
197 | #endif /* ENABLE_FEATURE_MDEV_RENAME */ | ||
196 | 198 | ||
197 | /* The rest (opt): command to run */ | 199 | /* The rest (opt): command to run */ |
198 | if (!next) | 200 | if (!next) |