aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-10-15 09:43:35 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-10-15 09:43:35 +0000
commite915a1a410b9852ddfaa0563922920219c2e6ed3 (patch)
tree2e76a0f67709279af7066532db33d652396f7907
parent81944c9e92991eff0d1a9fc289b21cc745f43f9c (diff)
downloadbusybox-w32-e915a1a410b9852ddfaa0563922920219c2e6ed3.tar.gz
busybox-w32-e915a1a410b9852ddfaa0563922920219c2e6ed3.tar.bz2
busybox-w32-e915a1a410b9852ddfaa0563922920219c2e6ed3.zip
sysctl: fix bug 3894 _for real_.
-rw-r--r--procps/sysctl.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/procps/sysctl.c b/procps/sysctl.c
index 90e47ea9a..0876a73de 100644
--- a/procps/sysctl.c
+++ b/procps/sysctl.c
@@ -234,19 +234,30 @@ static int sysctl_display_all(const char *path)
234 234
235static void sysctl_dots_to_slashes(char *name) 235static void sysctl_dots_to_slashes(char *name)
236{ 236{
237 char *cptr = name; 237 char *cptr, *last_good;
238 char *end = name + strlen(name) - 1;
238 239
239 /* Example from bug 3894: 240 /* Example from bug 3894:
240 * net.ipv4.conf.eth0.100.mc_forwarding -> 241 * net.ipv4.conf.eth0.100.mc_forwarding ->
241 * net/ipv4/conf/eth0.100/mc_forwarding */ 242 * net/ipv4/conf/eth0.100/mc_forwarding. NB:
242 while (*cptr != '\0') { 243 * net/ipv4/conf/eth0/mc_forwarding *also exists*,
244 * therefore we must start from the end, and if
245 * we replaced even one . -> /, start over again,
246 * but never replace dots before the position
247 * where replacement occurred. */
248 last_good = name - 1;
249 again:
250 cptr = end;
251 while (cptr > last_good) {
243 if (*cptr == '.') { 252 if (*cptr == '.') {
244 *cptr = '\0'; 253 *cptr = '\0';
245 if (access(name, F_OK) == 0) 254 if (access(name, F_OK) == 0) {
246 *cptr = '/'; 255 *cptr = '/';
247 else 256 last_good = cptr;
248 *cptr = '.'; 257 goto again;
258 }
259 *cptr = '.';
249 } 260 }
250 cptr++; 261 cptr--;
251 } 262 }
252} /* end sysctl_dots_to_slashes() */ 263} /* end sysctl_dots_to_slashes() */