From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 72FCB3858407; Mon, 29 Jan 2024 18:04:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 72FCB3858407 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1706551460; bh=PcixX/DbV1OSAYl3Cg9u0IjXYzqMLDlmbQm6/56HRkI=; h=From:To:Subject:Date:From; b=h03c+IRMVdHs4QIPCk+yX3mC0eQvGcq/cNsWPNfUSvAGy3Th8LHKSxxdhwTp+dYYr silrE54njUIfvyar6ZsNrVkOp7ewym/V3RpE/OVpDMbHDXELp/R28PwvfpfSKsMk4V /kO5abn0pxwxx+P30keINhyQW+d+hEdQ3XtqrO/g= 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: 07cc2f5b1a9b79ef3245f73d42b44da2970b0b7f X-Git-Newrev: c1ac467a9c8da6125122a9945fe7b7892cead826 Message-Id: <20240129180420.72FCB3858407@sourceware.org> Date: Mon, 29 Jan 2024 18:04:20 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c1ac467a9c8da6125122a9945fe7b7892cead826 commit c1ac467a9c8da6125122a9945fe7b7892cead826 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 })"