From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 9E6751F4B4 for ; Thu, 31 Dec 2020 21:55:02 +0000 (UTC) Received: from localhost ([::1]:35844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kv5uP-0001Qd-EG for normalperson@yhbt.net; Thu, 31 Dec 2020 16:55:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42338) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kv5u2-0001Hi-P7 for bug-gnulib@gnu.org; Thu, 31 Dec 2020 16:54:38 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:58876) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kv5u0-00040m-TM for bug-gnulib@gnu.org; Thu, 31 Dec 2020 16:54:38 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id C57FA16010F; Thu, 31 Dec 2020 13:54:35 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id A8hH6ZvqRBUv; Thu, 31 Dec 2020 13:54:34 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id A7B70160111; Thu, 31 Dec 2020 13:54:34 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id AdYPUkcot4lU; Thu, 31 Dec 2020 13:54:34 -0800 (PST) Received: from [192.168.1.9] (cpe-23-243-218-95.socal.res.rr.com [23.243.218.95]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 78AEA16010E; Thu, 31 Dec 2020 13:54:34 -0800 (PST) To: Adhemerval Zanella References: <20201230201507.2755086-1-adhemerval.zanella@linaro.org> <20201230201507.2755086-5-adhemerval.zanella@linaro.org> From: Paul Eggert Organization: UCLA Computer Science Department Subject: Re: [PATCH 5/5] posix: Sync fnmatch with gnulib Message-ID: Date: Thu, 31 Dec 2020 13:54:34 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <20201230201507.2755086-5-adhemerval.zanella@linaro.org> Content-Type: multipart/mixed; boundary="------------DD30BD9E349B21DF4FBE4D6C" Content-Language: en-US Received-SPF: pass client-ip=131.179.128.68; envelope-from=eggert@cs.ucla.edu; helo=zimbra.cs.ucla.edu X-Spam_score_int: -75 X-Spam_score: -7.6 X-Spam_bar: ------- X-Spam_report: (-7.6 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-3.399, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: libc-alpha@sourceware.org, bug-gnulib@gnu.org Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" This is a multi-part message in MIME format. --------------DD30BD9E349B21DF4FBE4D6C Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable On 12/30/20 12:15 PM, Adhemerval Zanella wrote: > - ssize_t level; > + size_t level; 'level' should be ptrdiff_t not ssize_t, for portability to=20 (now-ancient, but still allowed by POSIX) hosts where ssize_t is 32 bits=20 and size_t is 64 bits. > - CHAR str[]; > + CHAR str[FLEXIBLE_ARRAY_MEMBER]; This assumes C99 flex array members which is fine for glibc but dubious=20 for Gnulib; it should be safer to use __flexarr. > Because otherwise it triggers some glibc regressions: Thanks for spotting that. I installed the attached patch into Gnulib,=20 which should fix the glibc regressions and the other abovementioned=20 glitches, so that you should now be able to sync fnmatch from Gnulib=20 unchanged. --------------DD30BD9E349B21DF4FBE4D6C Content-Type: text/x-patch; charset=UTF-8; name="0002-fnmatch-merge-from-glibc-proposal.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0002-fnmatch-merge-from-glibc-proposal.patch" =46rom a7ad4b110fd6b7dde424dceb46c9c09c31cfbe69 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 31 Dec 2020 13:35:53 -0800 Subject: [PATCH 2/2] fnmatch: merge from glibc + proposal This merges the change proposed by Adhemerval Zanella in: https://sourceware.org/pipermail/libc-alpha/2020-December/121212.html which fixes a Gnulib bug that led to a failed assert. * lib/fnmatch_loop.c (EXT): Use signed level, not unsigned, and check that it stays nonnegative. Use __flexarr instead of FLEXIBLE_ARRAY_MEMBER, to port better to glibc. * tests/test-fnmatch.c (main): New test cases, taken from glibc. --- ChangeLog | 9 +++++++++ lib/fnmatch_loop.c | 7 +++---- tests/test-fnmatch.c | 10 ++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5da7c043a..661a1ee94 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2020-12-31 Paul Eggert =20 + fnmatch: merge from glibc + proposal + This merges the change proposed by Adhemerval Zanella in: + https://sourceware.org/pipermail/libc-alpha/2020-December/121212.html + which fixes a Gnulib bug that led to a failed assert. + * lib/fnmatch_loop.c (EXT): Use signed level, not unsigned, and + check that it stays nonnegative. Use __flexarr instead of + FLEXIBLE_ARRAY_MEMBER, to port better to glibc. + * tests/test-fnmatch.c (main): New test cases, taken from glibc. + glob: merge proposed glibc changes This merges the change proposed by Adhemerval Zanella in: https://sourceware.org/pipermail/libc-alpha/2020-December/121211.html diff --git a/lib/fnmatch_loop.c b/lib/fnmatch_loop.c index c533107a2..e5dac38b4 100644 --- a/lib/fnmatch_loop.c +++ b/lib/fnmatch_loop.c @@ -978,12 +978,12 @@ EXT (INT opt, const CHAR *pattern, const CHAR *stri= ng, const CHAR *string_end, bool no_leading_period, int flags, size_t alloca_used) { const CHAR *startp; - size_t level; + ptrdiff_t level; struct patternlist { struct patternlist *next; CHAR malloced; - CHAR str[FLEXIBLE_ARRAY_MEMBER]; + CHAR str __flexarr; } *list =3D NULL; struct patternlist **lastp =3D &list; size_t pattern_len =3D STRLEN (pattern); @@ -994,7 +994,7 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string= , const CHAR *string_end, =20 /* Parse the pattern. Store the individual parts in the list. */ level =3D 0; - for (startp =3D p =3D pattern + 1; ; ++p) + for (startp =3D p =3D pattern + 1; level >=3D 0; ++p) if (*p =3D=3D L_('\0')) { /* This is an invalid pattern. */ @@ -1065,7 +1065,6 @@ EXT (INT opt, const CHAR *pattern, const CHAR *stri= ng, const CHAR *string_end, *lastp =3D newp; = \ lastp =3D &newp->next NEW_PATTERN; - break; } } else if (*p =3D=3D L_('|')) diff --git a/tests/test-fnmatch.c b/tests/test-fnmatch.c index a094c1fa7..1d58689cf 100644 --- a/tests/test-fnmatch.c +++ b/tests/test-fnmatch.c @@ -52,5 +52,15 @@ main () */ ASSERT (res =3D fnmatch ("[/b", "[/b", 0) =3D=3D 0); =20 + ASSERT (fnmatch ("[[:alpha:]'[:alpha:]\0]", "a", 0) =3D=3D FNM_NOMATCH= ); + ASSERT (fnmatch ("[a[.\0.]]", "a", 0) =3D=3D FNM_NOMATCH); +#ifdef FNM_EXTMATCH + ASSERT (fnmatch ("**(!()", "**(!()", FNM_EXTMATCH) =3D=3D 0); +#endif +#ifdef FNM_LEADING_DIR + ASSERT (fnmatch ("x?y", "x/y/z", FNM_PATHNAME | FNM_LEADING_DIR) + =3D=3D FNM_NOMATCH); +#endif + return 0; } --=20 2.27.0 --------------DD30BD9E349B21DF4FBE4D6C--