From owner-svn-src-head@freebsd.org Sat May 9 15:56:03 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4F3842EDFEB; Sat, 9 May 2020 15:56:03 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49KBcz1PW6z41jQ; Sat, 9 May 2020 15:56:03 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2B2DA1E5EC; Sat, 9 May 2020 15:56:03 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 049Fu2YI051748; Sat, 9 May 2020 15:56:02 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 049Fu2Vp051746; Sat, 9 May 2020 15:56:02 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <202005091556.049Fu2Vp051746@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Sat, 9 May 2020 15:56:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r360849 - in head: share/man/man9 sys/kern X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: in head: share/man/man9 sys/kern X-SVN-Commit-Revision: 360849 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.32 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 May 2020 15:56:03 -0000 Author: emaste Date: Sat May 9 15:56:02 2020 New Revision: 360849 URL: https://svnweb.freebsd.org/changeset/base/360849 Log: remove %n support from printf(9) It can be dangerous and there is no need for it in the kernel. Inspired by Kees Cook's change in Linux, and later OpenBSD. Reviewed by: cem, gordon, philip Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D24760 Modified: head/share/man/man9/printf.9 head/sys/kern/subr_prf.c Modified: head/share/man/man9/printf.9 ============================================================================== --- head/share/man/man9/printf.9 Sat May 9 14:49:56 2020 (r360848) +++ head/share/man/man9/printf.9 Sat May 9 15:56:02 2020 (r360849) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 18, 2015 +.Dd May 9, 2020 .Dt PRINTF 9 .Os .Sh NAME @@ -83,7 +83,7 @@ parameter in the same manner as .Xr printf 3 . However, .Xr printf 9 -adds two other conversion specifiers. +adds two other conversion specifiers and omits one. .Pp The .Cm \&%b @@ -119,6 +119,10 @@ a time. The string is used as a delimiter between individual bytes. If present, a width directive will specify the number of bytes to display. By default, 16 bytes of data are output. +.Pp +The +.Cm \&%n +conversion specifier is not supported. .Pp The .Fn log Modified: head/sys/kern/subr_prf.c ============================================================================== --- head/sys/kern/subr_prf.c Sat May 9 14:49:56 2020 (r360848) +++ head/sys/kern/subr_prf.c Sat May 9 15:56:02 2020 (r360849) @@ -775,20 +775,24 @@ reswitch: switch (ch = (u_char)*fmt++) { lflag = 1; goto reswitch; case 'n': + /* + * We do not support %n in kernel, but consume the + * argument. + */ if (jflag) - *(va_arg(ap, intmax_t *)) = retval; + (void)va_arg(ap, intmax_t *); else if (qflag) - *(va_arg(ap, quad_t *)) = retval; + (void)va_arg(ap, quad_t *); else if (lflag) - *(va_arg(ap, long *)) = retval; + (void)va_arg(ap, long *); else if (zflag) - *(va_arg(ap, size_t *)) = retval; + (void)va_arg(ap, size_t *); else if (hflag) - *(va_arg(ap, short *)) = retval; + (void)va_arg(ap, short *); else if (cflag) - *(va_arg(ap, char *)) = retval; + (void)va_arg(ap, char *); else - *(va_arg(ap, int *)) = retval; + (void)va_arg(ap, int *); break; case 'o': base = 8;