Author: lwhsu Date: Mon Feb 10 20:53:59 2020 New Revision: 357745 URL: https://svnweb.freebsd.org/changeset/base/357745
Log: Restore the behavior of allowing empty string in a string sysctl Added as a special case to avoid unnecessary memory operations. Reviewed by: delphij Sponsored by: The FreeBSD Foundation Modified: head/sys/kern/kern_sysctl.c Modified: head/sys/kern/kern_sysctl.c ============================================================================== --- head/sys/kern/kern_sysctl.c Mon Feb 10 20:23:08 2020 (r357744) +++ head/sys/kern/kern_sysctl.c Mon Feb 10 20:53:59 2020 (r357745) @@ -1687,8 +1687,12 @@ sysctl_handle_string(SYSCTL_HANDLER_ARGS) return (error); if (req->newlen - req->newidx >= arg2 || - req->newlen - req->newidx <= 0) { + req->newlen - req->newidx < 0) { error = EINVAL; + } else if (req->newlen - req->newidx == 0) { + sx_xlock(&sysctlstringlock); + ((char *)arg1)[0] = '\0'; + sx_xunlock(&sysctlstringlock); } else { arg2 = req->newlen - req->newidx; tmparg = malloc(arg2, M_SYSCTLTMP, M_WAITOK); _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"