From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12436 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: libc-test octal corner cases Date: Wed, 31 Jan 2018 10:42:57 -0500 Message-ID: <20180131154257.GP1627@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="BjavXC7V3ilNTWHC" X-Trace: blaine.gmane.org 1517413289 27060 195.159.176.226 (31 Jan 2018 15:41:29 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 31 Jan 2018 15:41:29 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-12452-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jan 31 16:41:25 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1eguVY-0005rL-9n for gllmg-musl@m.gmane.org; Wed, 31 Jan 2018 16:41:08 +0100 Original-Received: (qmail 11920 invoked by uid 550); 31 Jan 2018 15:43:10 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 11875 invoked from network); 31 Jan 2018 15:43:09 -0000 Content-Disposition: inline Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:12436 Archived-At: --BjavXC7V3ilNTWHC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline musl commit b64539ae06aa91a407359238f4e909adb9bfab3d fixed some octal printing corner cases. I've written some tests to cover the affected functionality to go in libc-test. I just added them to the existing snprintf test rather than as a regression test since, despite it being a bug fix, these fit the general form and I think it makes sense to have them all in one place. Rich --BjavXC7V3ilNTWHC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="printf-octal.diff" diff --git a/src/functional/snprintf.c b/src/functional/snprintf.c index c96f151..70c1118 100644 --- a/src/functional/snprintf.c +++ b/src/functional/snprintf.c @@ -60,6 +60,20 @@ static const struct { { "%o", 15, "17" }, { "%#o", 15, "017" }, + /* octal: corner cases */ + { "%#o", 0, "0" }, + { "%#.0o", 0, "0" }, + { "%#.1o", 0, "0" }, + { "%#o", 1, "01" }, + { "%#.0o", 1, "01" }, + { "%#.1o", 1, "01" }, + { "%#04o", 1, "0001" }, + { "%#04.0o", 1, " 01" }, + { "%#04.1o", 1, " 01" }, + { "%04o", 1, "0001" }, + { "%04.0o", 1, " 1" }, + { "%04.1o", 1, " 1" }, + { NULL, 0.0, NULL } }; --BjavXC7V3ilNTWHC--