public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org, Frederic Berat <fberat@redhat.com>
Subject: [PATCH 1/3] posix: Fix test-errno build with fortify enable
Date: Fri, 21 Jul 2023 09:18:15 -0300	[thread overview]
Message-ID: <20230721121817.1978446-2-adhemerval.zanella@linaro.org> (raw)
In-Reply-To: <20230721121817.1978446-1-adhemerval.zanella@linaro.org>

With gcc 11.3.1, building with -D_FORTIFY_SOURCE=2 shows:

In function ‘getgroups’,
    inlined from ‘do_test’ at test-errno.c:129:12:
../misc/sys/cdefs.h:195:6: error: argument 1 value -1 is negative
[-Werror=stringop-overflow=]
  195 |    ? __ ## f ## _alias (__VA_ARGS__)
      \
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../posix/bits/unistd.h:115:10: note: in expansion of macro
‘__glibc_fortify’
  115 |   return __glibc_fortify (getgroups, __size, sizeof (__gid_t),
      |          ^~~~~~~~~~~~~~~
../posix/bits/unistd.h: In function ‘do_test’:
../posix/bits/unistd-decl.h:135:28: note: in a call to function
‘__getgroups_alias’ declared with attribute ‘access (write_only, 2, 1)’
  135 | extern int __REDIRECT_NTH (__getgroups_alias, (int __size,
      __gid_t __list[]),
      |                            ^~~~~~~~~~~~~~~~~
../misc/sys/cdefs.h:264:6: note: in definition of macro ‘__REDIRECT_NTH’
  264 |      name proto __asm__ (__ASMNAME (#alias)) __THROW

It builds fine with gcc 12 and gcc 13.

Checked on x86_64-linux-gnu.
---
 posix/test-errno.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/posix/test-errno.c b/posix/test-errno.c
index 305bc42938..3ef711bb41 100644
--- a/posix/test-errno.c
+++ b/posix/test-errno.c
@@ -17,6 +17,10 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <libc-diag.h>
+/* Triggered by getgroup fortify wrapper.  */
+DIAG_IGNORE_NEEDS_COMMENT (6, "-Wstringop-overflow");
+
 #include <errno.h>
 #include <limits.h>
 #include <grp.h>
@@ -34,7 +38,6 @@
 #include <sys/uio.h>
 #include <unistd.h>
 #include <netinet/in.h>
-#include <libc-diag.h>
 
 /* This is not an exhaustive test: only system calls that can be
    persuaded to fail with a consistent error code and no side effects
-- 
2.34.1


  reply	other threads:[~2023-07-21 12:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-21 12:18 [PATCH 0/3] Fix some issues with tests when fortify is enabled Adhemerval Zanella
2023-07-21 12:18 ` Adhemerval Zanella [this message]
2023-07-24 12:16   ` [PATCH 1/3] posix: Fix test-errno build with fortify enable Carlos O'Donell
2023-07-24 13:03     ` Adhemerval Zanella Netto
2023-07-21 12:18 ` [PATCH 2/3] string: Fix bug-strncat1 with fortify enabled Adhemerval Zanella
2023-07-24 12:36   ` Carlos O'Donell
2023-07-24 14:24     ` Siddhesh Poyarekar
2023-07-24 14:26       ` Adhemerval Zanella Netto
2023-07-24 14:36         ` Siddhesh Poyarekar
2023-07-21 12:18 ` [PATCH 3/3] string: Fix tester " Adhemerval Zanella
2023-07-24 12:38   ` Carlos O'Donell
2023-07-24 12:39 ` [PATCH 0/3] Fix some issues with tests when fortify is enabled Carlos O'Donell
2023-07-24 18:42   ` Adhemerval Zanella Netto
2023-07-24 18:45     ` Andreas K. Huettel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230721121817.1978446-2-adhemerval.zanella@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=fberat@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).