From b21414f77c0f745b2d6d6853e8802db18ca7e850 Mon Sep 17 00:00:00 2001 From: bapt Date: Wed, 14 Oct 2015 06:26:55 +0000 Subject: [PATCH] Trim spaces at the end of the buffer before trying to convert it to an oid This allows to write entries in sysctl.conf with spaces before the '=' like kern.ipc.shmmax = 9663676416 Sponsored by: Gandi.net git-svn-id: svn://svn.freebsd.org/base/stable/10@289291 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sbin/sysctl/sysctl.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index f9207f1de..97628a297 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -233,6 +233,12 @@ parse(const char *string, int lineno) newval = cp; newsize = strlen(cp); } + /* Trim spaces */ + cp = bufp + strlen(bufp) - 1; + while (cp >= bufp && isspace((int)*cp)) { + *cp = '\0'; + cp--; + } len = name2oid(bufp, mib); if (len < 0) { -- 2.45.0