From patchwork Tue Dec 4 18:01:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel F. T. Gomes" X-Patchwork-Id: 30535 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Received: (qmail 78557 invoked by alias); 4 Dec 2018 18:01:48 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 78544 invoked by uid 89); 4 Dec 2018 18:01:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=drepper, Drepper, D*br, side-effect X-HELO: mo19.mail-out.ovh.net Date: Tue, 4 Dec 2018 16:01:27 -0200 From: "Gabriel F. T. Gomes" To: Adhemerval Zanella CC: Subject: Re: [PATCH v3 6/7] Use PRINTF_FORTIFY instead of _IO_FLAGS2_FORTIFY (bug 11319) Message-ID: <20181204160127.0ca1ec00@tereshkova> In-Reply-To: <4eff527e-f466-d778-bc14-00727be3e1b1@linaro.org> References: <20181115214449.19262-1-gabriel@inconstante.eti.br> <20181115214449.19262-7-gabriel@inconstante.eti.br> <878aa68c-1a30-69d6-ae01-4acd6d80ccaa@linaro.org> <20181204141946.26ba9107@tereshkova> <4eff527e-f466-d778-bc14-00727be3e1b1@linaro.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 13907960076424564425 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudeffedguddtkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd On Tue, 04 Dec 2018, Adhemerval Zanella wrote: >Thanks for confirm it, could you attach the add the testcase as well? >I would prefer to push along with the patch itself, and there is no need >to send a new version for the whole set. Just update this one. This is the patch (I hope my email client doesn't screw it)... From a583fded669048e7d58c760810e30758a5ede286 Mon Sep 17 00:00:00 2001 From: "Gabriel F. T. Gomes" Date: Tue, 4 Dec 2018 15:57:57 -0200 Subject: [PATCH] Add test for bug 11319 The commit commit 7ca890b88e6ab7624afb1742a9fffb37ad5b3fc3 Author: Ulrich Drepper Date: Wed Feb 24 16:07:57 2010 -0800 Fix reporting of I/O errors in *dprintf functions. fixed bug 11319 for dprintf and vdprintf, however, it did not fix it for __dprintf_chk and __vdprintf_chk. As a side-effect of the refactoring of libio functions, this bug is also fixed for the foritified functions. This patch adds a test case to avoid regressions. Tested for powerpc64le and x86_64. * stdio-common/Makefile (tests): Add tst-bz11319 and tst-bz11319-fortify2. (CFLAGS-tst-bz11319-fortify2.c): New macro. * stdio-common/tst-bz11319-fortify2.c: New file. * stdio-common/tst-bz11319.c: Likewise. --- stdio-common/Makefile | 6 ++++- stdio-common/tst-bz11319-fortify2.c | 1 + stdio-common/tst-bz11319.c | 48 +++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 stdio-common/tst-bz11319-fortify2.c create mode 100644 stdio-common/tst-bz11319.c From a583fded669048e7d58c760810e30758a5ede286 Mon Sep 17 00:00:00 2001 From: "Gabriel F. T. Gomes" Date: Tue, 4 Dec 2018 15:57:57 -0200 Subject: [PATCH] Add test for bug 11319 The commit commit 7ca890b88e6ab7624afb1742a9fffb37ad5b3fc3 Author: Ulrich Drepper Date: Wed Feb 24 16:07:57 2010 -0800 Fix reporting of I/O errors in *dprintf functions. fixed bug 11319 for dprintf and vdprintf, however, it did not fix it for __dprintf_chk and __vdprintf_chk. As a side-effect of the refactoring of libio functions, this bug is also fixed for the foritified functions. This patch adds a test case to avoid regressions. Tested for powerpc64le and x86_64. * stdio-common/Makefile (tests): Add tst-bz11319 and tst-bz11319-fortify2. (CFLAGS-tst-bz11319-fortify2.c): New macro. * stdio-common/tst-bz11319-fortify2.c: New file. * stdio-common/tst-bz11319.c: Likewise. --- stdio-common/Makefile | 6 ++++- stdio-common/tst-bz11319-fortify2.c | 1 + stdio-common/tst-bz11319.c | 48 +++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 stdio-common/tst-bz11319-fortify2.c create mode 100644 stdio-common/tst-bz11319.c diff --git a/stdio-common/Makefile b/stdio-common/Makefile index 84bad1fafe..8978b3fb1f 100644 --- a/stdio-common/Makefile +++ b/stdio-common/Makefile @@ -64,7 +64,7 @@ tests := tstscanf test_rdwr test-popen tstgetln test-fseek \ tst-vfprintf-user-type \ tst-vfprintf-mbs-prec \ tst-scanf-round \ - tst-renameat2 \ + tst-renameat2 tst-bz11319 tst-bz11319-fortify2 \ test-srcs = tst-unbputc tst-printf tst-printfsz-islongdouble @@ -164,6 +164,10 @@ CFLAGS-test_rdwr.c += -DOBJPFX=\"$(objpfx)\" # tst-gets.c tests a deprecated function. CFLAGS-tst-gets.c += -Wno-deprecated-declarations +# BZ #11319 was first fixed for regular vdprintf, then reopened because +# the fortified version had the same bug. +CFLAGS-tst-bz11319-fortify2.c += -D_FORTIFY_SOURCE=2 + CPPFLAGS += $(libio-mtsafe) $(objpfx)tst-setvbuf1.out: /dev/null $(objpfx)tst-setvbuf1 diff --git a/stdio-common/tst-bz11319-fortify2.c b/stdio-common/tst-bz11319-fortify2.c new file mode 100644 index 0000000000..a8df9a39bd --- /dev/null +++ b/stdio-common/tst-bz11319-fortify2.c @@ -0,0 +1 @@ +#include diff --git a/stdio-common/tst-bz11319.c b/stdio-common/tst-bz11319.c new file mode 100644 index 0000000000..ce2dee13ae --- /dev/null +++ b/stdio-common/tst-bz11319.c @@ -0,0 +1,48 @@ +/* Regression test for bug 11319. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + +#include +#include +#include +#include + +#include + +static int +do_test (void) +{ + int ret; + int fd = eventfd(0, 0); + + /* man 2 eventfd: + + A write(2) will fail with the error EINVAL if the size of the + supplied buffer is less than 8 bytes... */ + ret = dprintf(fd, "%d", 0); + + TEST_VERIFY (ret < 0); + TEST_COMPARE (errno, EINVAL); + + return 0; +} + +#include -- 2.14.5