From 3985929b6dcd9f0d642a7e57d71b3e216afa7369 Mon Sep 17 00:00:00 2001 From: sin Date: Thu, 17 Apr 2014 17:01:57 +0100 Subject: [PATCH] Error out if there are multiple separators in sysctl --- sysctl.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/sysctl.c b/sysctl.c index 6a764e5..159180a 100644 --- 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) {