Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Oct 2015 08:56:02 +0000 (UTC)
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r288981 - head/sbin/sysctl
Message-ID:  <201510070856.t978u2mZ048215@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bapt
Date: Wed Oct  7 08:56:01 2015
New Revision: 288981
URL: https://svnweb.freebsd.org/changeset/base/288981

Log:
  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
  
  MFC after:	1 week
  Sponsored by:	Gandi.net

Modified:
  head/sbin/sysctl/sysctl.c

Modified: head/sbin/sysctl/sysctl.c
==============================================================================
--- head/sbin/sysctl/sysctl.c	Wed Oct  7 06:32:34 2015	(r288980)
+++ head/sbin/sysctl/sysctl.c	Wed Oct  7 08:56:01 2015	(r288981)
@@ -262,6 +262,12 @@ parse(const char *string, int lineno)
 		newvalstr = 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) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510070856.t978u2mZ048215>