From 8795154eaca56f6904c0a9cd306451e2850d4a5b Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Wed, 12 Oct 2011 23:21:34 +0200 Subject: [PATCH] sysctl: warn when separators are repeated For some reason sysctl earlier allowed quite strange separators. % sysctl kernel./.pty.nr kernel./.pty.nr = 6 % sysctl kernel///pty//////////nr kernel...pty..........nr = 6 This commit does not disallow that sort of constructs, but will warn about them. In future disallowing these might be reasonable thing to do. % sysctl kernel./.pty.nr sysctl: separators should not be repeated: ./.pty.nr kernel./.pty.nr = 6 Signed-off-by: Sami Kerola --- sysctl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sysctl.c b/sysctl.c index 5432b773..b7d89a3b 100644 --- a/sysctl.c +++ b/sysctl.c @@ -63,11 +63,16 @@ static char *pattern; static int pattern_match(const char *string, const char *pattern); static void slashdot(char *restrict p, char old, char new){ + int warned = 1; p = strpbrk(p,"/."); if(!p) return; /* nothing -- can't be, but oh well */ if(*p==new) return; /* already in desired format */ while(p){ char c = *p; + if((*(p+1) == '/' || *(p+1) == '.') && warned) { + warnx(_("separators should not be repeated: %s"), p); + warned = 0; + } if(c==old) *p=new; if(c==new) *p=old; p = strpbrk(p+1,"/.");