From owner-svn-src-all@freebsd.org Tue Aug 14 22:57:29 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C89511068AB3; Tue, 14 Aug 2018 22:57:29 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7C3358CBF3; Tue, 14 Aug 2018 22:57:29 +0000 (UTC) (envelope-from pfg@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 5D19421F7F; Tue, 14 Aug 2018 22:57:29 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w7EMvTVC088202; Tue, 14 Aug 2018 22:57:29 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w7EMvTIZ088201; Tue, 14 Aug 2018 22:57:29 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201808142257.w7EMvTIZ088201@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Tue, 14 Aug 2018 22:57:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r337823 - stable/11/usr.bin/printf X-SVN-Group: stable-11 X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: stable/11/usr.bin/printf X-SVN-Commit-Revision: 337823 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Aug 2018 22:57:30 -0000 Author: pfg Date: Tue Aug 14 22:57:28 2018 New Revision: 337823 URL: https://svnweb.freebsd.org/changeset/base/337823 Log: MFC r337458, r337618: Fix printf(1) ignores width and precision in %b format. The precision with the conversion specifier b is specified by POSIX: see point 7 in the reference documentation. Include fix from jilles@ to avoid breaking the testsuite. Reference: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html PR: 229641 Reported by: Rudolf Cejka Submitted by: Garrett D'Amore (illumos) Modified: stable/11/usr.bin/printf/printf.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/printf/printf.c ============================================================================== --- stable/11/usr.bin/printf/printf.c Tue Aug 14 20:45:43 2018 (r337822) +++ stable/11/usr.bin/printf/printf.c Tue Aug 14 22:57:28 2018 (r337823) @@ -1,4 +1,5 @@ /*- + * Copyright 2018 Staysail Systems, Inc. * Copyright 2014 Garrett D'Amore * Copyright 2010 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 1989, 1993 @@ -378,13 +379,16 @@ printf_doformat(char *fmt, int *rval) char *p; int getout; - p = strdup(getstr()); - if (p == NULL) { + /* Convert "b" to "s" for output. */ + start[strlen(start) - 1] = 's'; + if ((p = strdup(getstr())) == NULL) { warnx("%s", strerror(ENOMEM)); return (NULL); } getout = escape(p, 0, &len); - fputs(p, stdout); + PF(start, p); + /* Restore format for next loop. */ + free(p); if (getout) return (end_fmt);