From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 4B606385840E; Fri, 9 Feb 2024 17:38:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B606385840E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1707500321; bh=YYdU+IiV0j4oRKydK23QPM5oRJ8FYmKf0OvsmyKUD7A=; h=From:To:Subject:Date:From; b=oyS76j7lcmBTgnnSI4PLtOJYDVr3Bs9Sph2CK0tj9hP5uCiVTMN7IyaDPA4sVBrEG 1u+opWBvbP6xN2xpGtc1/vAiS8taEtc4bYdfmSiX8jrhCWgcxhE0UPLqQtvD/Y2DLl bQVdISJLJvCQB5slf/qCoEtGNQNUxji50AAsGFe8= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc/azanella/clang] posix: Remove the __strcpy_chk from glob tests X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella X-Git-Refname: refs/heads/azanella/clang X-Git-Oldrev: 95875f9a30e6bd2661287e0a5d38a73ec39540d8 X-Git-Newrev: 9920e9108949d8031a61369a4623fa359ee13925 Message-Id: <20240209173841.4B606385840E@sourceware.org> Date: Fri, 9 Feb 2024 17:38:41 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=9920e9108949d8031a61369a4623fa359ee13925 commit 9920e9108949d8031a61369a4623fa359ee13925 Author: Adhemerval Zanella 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 #include #include +#include #include @@ -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 })"