ubase

suckless linux base utils
git clone git://git.2f30.org/ubase.git
Log | Files | Refs | README | LICENSE

commit 3985929b6dcd9f0d642a7e57d71b3e216afa7369
parent 0897d999e63be4e2e6e5c385b72a02dd649086ee
Author: sin <sin@2f30.org>
Date:   Thu, 17 Apr 2014 17:01:57 +0100

Error out if there are multiple separators in sysctl

Diffstat:
sysctl.c | 18++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/sysctl.c b/sysctl.c @@ -131,17 +131,27 @@ main(int argc, char *argv[]) usage(); for (i = 0; i < argc; i++) { - value = NULL; - variable = argv[i]; - p = strchr(variable, '='); + for (p = argv[i]; *p; p++) { + if (p[0] == '.' && p[1] == '.') { + weprintf("malformed input: %s\n", argv[i]); + break; + } + } + if (*p != '\0') + continue; + p = strchr(argv[i], '='); if (p) { if (p[1] == '\0') { - weprintf("malformed sysctl: %s\n", argv[i]); + weprintf("malformed input: %s\n", argv[i]); continue; } *p = '\0'; value = &p[1]; + } else { + value = NULL; } + variable = argv[i]; + if (variable) { if (value) { if (setsysctl(variable, value) < 0) {