From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 69760 invoked by alias); 7 Sep 2017 22:14:28 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 69585 invoked by uid 89); 7 Sep 2017 22:14:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=a*b, H*M:d75b, seemingly X-HELO: zimbra.cs.ucla.edu Subject: Re: [PATCH 9/9] posix: Fix glob with GLOB_NOCHECK returning modified patterns (BZ#10246) To: Adhemerval Zanella , libc-alpha@sourceware.org References: <1504643122-14874-1-git-send-email-adhemerval.zanella@linaro.org> <1504643122-14874-10-git-send-email-adhemerval.zanella@linaro.org> From: Paul Eggert Message-ID: <2a8058e8-4859-d75b-a16d-7ea0dd61ffd7@cs.ucla.edu> Date: Thu, 07 Sep 2017 22:14:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <1504643122-14874-10-git-send-email-adhemerval.zanella@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-SW-Source: 2017-09/txt/msg00315.txt.bz2 Although this is a definite bug and the patch fixes this instance of it, I'= m=20 afraid other instances remain unfixed. For example: glob_t g; glob ("//a*b", 0, NULL, &g) can do the wrong thing, since glob calls opendir on "/" instead of "//", an= d on=20 some platforms "/" and "//" are different directories (POSIX allows this as= a=20 special exception). A more serious example. If you do this: ln -s /no-such-file globlink1 ln -s . globlink2 then: glob_t g; int res =3D glob ("globlink[12]/", 0, NULL, &g); assert (res =3D=3D 0 && g.gl_pathc =3D=3D 1); assert (strcmp (g.gl_pathv[0], "globlink2/") =3D=3D 0); fails, since glob gets confused about directories and slashes and mistakenl= y=20 returns two results. Although this bug is seemingly unrelated, the underlyi= ng=20 cause is the same: glob gets confused about whether to include or exclude=20 slashes when doing its tests. I'll take a look at it, though the fix won't be trivial. PS. This finishes my review of this patchset. Patches 1-8 are OK to be=20 installed, with the trivial changes I suggested earlier. This patch (patch = 9)=20 I'd like to hold off on, until we've had a chance to work out a=20 more-comprehensive fix. PPS. I'm still slowly wending my way through your original patchset. Most=20 recently I looked at "[PATCH 07/18] posix: User LOGIN_NAME_MAX for all user= =20 names in glob" = . I'm=20 afraid a good fix needs to be hairier there too, as POSIX does not require= =20 LOGIN_NAME_MAX to be suitable for a stack-based buffer, or even to be defin= ed. I=20 have a partly-drafted patch which I hope to finish in the not-too-distant f= uture.