public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Adhemerval Zanella <azanella@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc/azanella/clang] posix: Remove the __strcpy_chk from glob tests Date: Wed, 7 Feb 2024 14:13:54 +0000 (GMT) [thread overview] Message-ID: <20240207141354.9D21C3858297@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=67722207ece36642860eff68481793ea963b5cd5 commit 67722207ece36642860eff68481793ea963b5cd5 Author: Adhemerval Zanella <adhemerval.zanella@linaro.org> Date: Wed Aug 30 09:00:04 2023 -0300 posix: Remove the __strcpy_chk from glob tests Not all compiler supports the builtin. Diff: --- posix/tst-glob_lstat_compat.c | 8 +++++++- posix/tst-gnuglob-skeleton.c | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/posix/tst-glob_lstat_compat.c b/posix/tst-glob_lstat_compat.c index 6ea3b062f0..70d5c54838 100644 --- a/posix/tst-glob_lstat_compat.c +++ b/posix/tst-glob_lstat_compat.c @@ -173,7 +173,13 @@ my_readdir (void *gdir) dir->d.d_type = filesystem[dir->idx].type; - __strcpy_chk (dir->d.d_name, filesystem[dir->idx].name, NAME_MAX); + { + size_t len = strlen (filesystem[dir->idx].name); + if (len >= NAME_MAX) + FAIL_EXIT1 ("[%s] entry name larger than NAME_MAX (%d)", __func__, + NAME_MAX); + memcpy (dir->d.d_name, filesystem[dir->idx].name, len + 1); + } ++dir->idx; diff --git a/posix/tst-gnuglob-skeleton.c b/posix/tst-gnuglob-skeleton.c index 145744199b..e6f39455ff 100644 --- a/posix/tst-gnuglob-skeleton.c +++ b/posix/tst-gnuglob-skeleton.c @@ -35,6 +35,7 @@ #include <stdlib.h> #include <string.h> #include <sys/stat.h> +#include <support/check.h> #include <support/test-driver.h> @@ -222,7 +223,13 @@ my_readdir (void *gdir) dir->d.d_type = filesystem[dir->idx].type; - __strcpy_chk (dir->d.d_name, filesystem[dir->idx].name, NAME_MAX); + { + size_t len = strlen (filesystem[dir->idx].name); + if (len >= NAME_MAX) + FAIL_EXIT1 ("[%s] entry name larger than NAME_MAX (%d)", __func__, + NAME_MAX); + memcpy (dir->d.d_name, filesystem[dir->idx].name, len + 1); + } if (test_verbose > 0) printf ("info: my_readdir ({ level: %d, idx: %ld })"
next reply other threads:[~2024-02-07 14:13 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-02-07 14:13 Adhemerval Zanella [this message] -- strict thread matches above, loose matches on Subject: below -- 2024-04-17 20:14 Adhemerval Zanella 2024-04-02 16:00 Adhemerval Zanella 2024-02-09 17:38 Adhemerval Zanella 2024-01-29 18:04 Adhemerval Zanella 2023-12-21 19:00 Adhemerval Zanella 2023-09-28 17:58 Adhemerval Zanella 2023-08-30 12:43 Adhemerval Zanella
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=20240207141354.9D21C3858297@sourceware.org \ --to=azanella@sourceware.org \ --cc=glibc-cvs@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: linkBe 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).