[{"id":1764976,"web_url":"http://patchwork.ozlabs.org/comment/1764976/","msgid":"<2a8058e8-4859-d75b-a16d-7ea0dd61ffd7@cs.ucla.edu>","list_archive_url":null,"date":"2017-09-07T22:14:15","subject":"Re: [PATCH 9/9] posix: Fix glob with GLOB_NOCHECK returning modified\n\tpatterns (BZ#10246)","submitter":{"id":4434,"url":"http://patchwork.ozlabs.org/api/people/4434/","name":"Paul Eggert","email":"eggert@CS.UCLA.EDU"},"content":"Although this is a definite bug and the patch fixes this instance of it, I'm \nafraid other instances remain unfixed. For example:\n\n    glob_t g; glob (\"//a*b\", 0, NULL, &g)\n\ncan do the wrong thing, since glob calls opendir on \"/\" instead of \"//\", and on \nsome platforms \"/\" and \"//\" are different directories (POSIX allows this as a \nspecial exception).\n\nA more serious example. If you do this:\n\n   ln -s /no-such-file globlink1\n   ln -s . globlink2\n\nthen:\n\n       glob_t g;\n       int res = glob (\"globlink[12]/\", 0, NULL, &g);\n       assert (res == 0 && g.gl_pathc == 1);\n       assert (strcmp (g.gl_pathv[0], \"globlink2/\") == 0);\n\nfails, since glob gets confused about directories and slashes and mistakenly \nreturns two results. Although this bug is seemingly unrelated, the underlying \ncause is the same: glob gets confused about whether to include or exclude \nslashes when doing its tests.\n\nI'll take a look at it, though the fix won't be trivial.\n\nPS. This finishes my review of this patchset. Patches 1-8 are OK to be \ninstalled, with the trivial changes I suggested earlier. This patch (patch 9) \nI'd like to hold off on, until we've had a chance to work out a \nmore-comprehensive fix.\n\nPPS. I'm still slowly wending my way through your original patchset. Most \nrecently I looked at \"[PATCH 07/18] posix: User LOGIN_NAME_MAX for all user \nnames in glob\" <https://sourceware.org/ml/libc-alpha/2017-08/msg00447.html>. I'm \nafraid a good fix needs to be hairier there too, as POSIX does not require \nLOGIN_NAME_MAX to be suitable for a stack-based buffer, or even to be defined. I \nhave a partly-drafted patch which I hope to finish in the not-too-distant future.","headers":{"Return-Path":"<libc-alpha-return-84317-incoming=patchwork.ozlabs.org@sourceware.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list libc-alpha@sourceware.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=sourceware.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=libc-alpha-return-84317-incoming=patchwork.ozlabs.org@sourceware.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tsecure) header.d=sourceware.org header.i=@sourceware.org\n\theader.b=\"xBSeTJgv\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xpF9l0sDTz9sCZ\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  8 Sep 2017 08:14:34 +1000 (AEST)","(qmail 69760 invoked by alias); 7 Sep 2017 22:14:28 -0000","(qmail 69585 invoked by uid 89); 7 Sep 2017 22:14:27 -0000"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:subject:to:references:from:message-id:date\n\t:mime-version:in-reply-to:content-type\n\t:content-transfer-encoding; q=dns; s=default; b=JPzIm6fbDZU4sSMV\n\tRQrNzrW32I7IJK73s1P5XM4KlN07vziSui5PmfXqSoQbJtCbK8WU4TsvpgpNDSLq\n\tAIpfcK6mFdBZo2V6lBQykeJfyrx2SM1cfPofHPagSZvHbckQgiM8n0MPqWQGxzR0\n\tq/C2qRxDCqYx6RRjJk+yP5MhKTU=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:subject:to:references:from:message-id:date\n\t:mime-version:in-reply-to:content-type\n\t:content-transfer-encoding; s=default; bh=CT268pwC7gnX4PJ234gTJO\n\tb5QEQ=; b=xBSeTJgv+gjsW4qiQF8Y9Za9/N+j9qtyvQWXQ+ar3rK5OiT4kgfdkg\n\tFRtbLGPSLZG+NjMHMhsXdlQjiy9LHnSWvUDtnuW2h0L05504FDudqRDr7owezoPv\n\tGyFMA3Ke5Ij4wQ2TqnON4ODE5nugIXDsFhuvBsA9a74ihLx7RWUA0=","Mailing-List":"contact libc-alpha-help@sourceware.org; run by ezmlm","Precedence":"bulk","List-Id":"<libc-alpha.sourceware.org>","List-Unsubscribe":"<mailto:libc-alpha-unsubscribe-incoming=patchwork.ozlabs.org@sourceware.org>","List-Subscribe":"<mailto:libc-alpha-subscribe@sourceware.org>","List-Archive":"<http://sourceware.org/ml/libc-alpha/>","List-Post":"<mailto:libc-alpha@sourceware.org>","List-Help":"<mailto:libc-alpha-help@sourceware.org>,\n\t<http://sourceware.org/ml/#faqs>","Sender":"libc-alpha-owner@sourceware.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-2.3 required=5.0 tests=AWL, BAYES_00,\n\tRP_MATCHES_RCVD,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=a*b, H*M:d75b,\n\tseemingly","X-HELO":"zimbra.cs.ucla.edu","Subject":"Re: [PATCH 9/9] posix: Fix glob with GLOB_NOCHECK returning modified\n\tpatterns (BZ#10246)","To":"Adhemerval Zanella <adhemerval.zanella@linaro.org>,\n\tlibc-alpha@sourceware.org","References":"<1504643122-14874-1-git-send-email-adhemerval.zanella@linaro.org>\n\t<1504643122-14874-10-git-send-email-adhemerval.zanella@linaro.org>","From":"Paul Eggert <eggert@cs.ucla.edu>","Message-ID":"<2a8058e8-4859-d75b-a16d-7ea0dd61ffd7@cs.ucla.edu>","Date":"Thu, 7 Sep 2017 15:14:15 -0700","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/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"}},{"id":1765176,"web_url":"http://patchwork.ozlabs.org/comment/1765176/","msgid":"<caf37ff1-497f-a091-60af-ef813d71e888@linaro.org>","list_archive_url":null,"date":"2017-09-08T09:15:57","subject":"Re: [PATCH 9/9] posix: Fix glob with GLOB_NOCHECK returning modified\n\tpatterns (BZ#10246)","submitter":{"id":66065,"url":"http://patchwork.ozlabs.org/api/people/66065/","name":"Adhemerval Zanella Netto","email":"adhemerval.zanella@linaro.org"},"content":"On 08/09/2017 00:14, Paul Eggert wrote:\n> Although this is a definite bug and the patch fixes this instance of\n> it, I'm afraid other instances remain unfixed. For example:\n>\n>    glob_t g; glob (\"//a*b\", 0, NULL, &g)\n>\n> can do the wrong thing, since glob calls opendir on \"/\" instead of\n> \"//\", and on some platforms \"/\" and \"//\" are different directories\n> (POSIX allows this as a special exception).\n>\n> A more serious example. If you do this:\n>\n>   ln -s /no-such-file globlink1\n>   ln -s . globlink2\n>\n> then:\n>\n>       glob_t g;\n>       int res = glob (\"globlink[12]/\", 0, NULL, &g);\n>       assert (res == 0 && g.gl_pathc == 1);\n>       assert (strcmp (g.gl_pathv[0], \"globlink2/\") == 0);\n>\n> fails, since glob gets confused about directories and slashes and\n> mistakenly returns two results. Although this bug is seemingly\n> unrelated, the underlying cause is the same: glob gets confused about\n> whether to include or exclude slashes when doing its tests.\n>\n> I'll take a look at it, though the fix won't be trivial.\n>\n> PS. This finishes my review of this patchset. Patches 1-8 are OK to be\n> installed, with the trivial changes I suggested earlier. This patch\n> (patch 9) I'd like to hold off on, until we've had a chance to work\n> out a more-comprehensive fix.\nFair enough, I will hold patch 9 push and take a look at the examples you\nbrought up.  Thanks for the follow up.\n\n>\n> PPS. I'm still slowly wending my way through your original patchset.\n> Most recently I looked at \"[PATCH 07/18] posix: User LOGIN_NAME_MAX\n> for all user names in glob\"\n> <https://sourceware.org/ml/libc-alpha/2017-08/msg00447.html>. I'm\n> afraid a good fix needs to be hairier there too, as POSIX does not\n> require LOGIN_NAME_MAX to be suitable for a stack-based buffer, or\n> even to be defined. I have a partly-drafted patch which I hope to\n> finish in the not-too-distant future.\nAlright, my initial patch was to adequate it to glibc code (which does\ndefine a actual limit suitable to stack allocation) and get rid of any\nalloca usage.  My understanding, based on gnulib commit 064df0b0c,\nis it should not impose a limit on user name length. \n\nSo currently in a patchset I am intended to send after this one, user\nname handling is now based on my char_array struct and thus allocates\nthe user_name dinamically if required.","headers":{"Return-Path":"<libc-alpha-return-84375-incoming=patchwork.ozlabs.org@sourceware.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list libc-alpha@sourceware.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=sourceware.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=libc-alpha-return-84375-incoming=patchwork.ozlabs.org@sourceware.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tsecure) header.d=sourceware.org header.i=@sourceware.org\n\theader.b=\"VO5YUFI8\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xpWsR1SR1z9sCZ\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  8 Sep 2017 19:16:27 +1000 (AEST)","(qmail 98084 invoked by alias); 8 Sep 2017 09:16:21 -0000","(qmail 97513 invoked by uid 89); 8 Sep 2017 09:16:21 -0000"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:subject:to:references:from:message-id:date\n\t:mime-version:in-reply-to:content-type\n\t:content-transfer-encoding; q=dns; s=default; b=bVLG1kaPIS0s3jXD\n\trCm8XKV67azSncv1xQeH8QZcF+PvllWGwjL8VujLdUKzfJib54KBr2KeHZcgtnpR\n\tcbtaXSd9I9a8f1ZZXNZWvo04KjT5QML9ZXzU63qjyrIN7lqBvkoF2XWTElyh6VZN\n\t6uMWKJJtRIO335vkfWCmsDUWpOo=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:subject:to:references:from:message-id:date\n\t:mime-version:in-reply-to:content-type\n\t:content-transfer-encoding; s=default; bh=kQQ1unLjLL+/3vOxgY8Exi\n\tpnKGg=; b=VO5YUFI86goGoZKPcn6jh+JGzN8jIAyUn4ZDzRs2+cL9wbGH8ZLVtt\n\tYLy9PvCcgw4aRxHU/q16LyxxWVVHxUYiSXx1qP+OrNmMLEdwqOJ26sg9JASNzMoR\n\tRHriIKyw77YQzx+VBNUeMUuNuoWhOwp8os0tVcqyvk3jlE7AMHZz4=","Mailing-List":"contact libc-alpha-help@sourceware.org; run by ezmlm","Precedence":"bulk","List-Id":"<libc-alpha.sourceware.org>","List-Unsubscribe":"<mailto:libc-alpha-unsubscribe-incoming=patchwork.ozlabs.org@sourceware.org>","List-Subscribe":"<mailto:libc-alpha-subscribe@sourceware.org>","List-Archive":"<http://sourceware.org/ml/libc-alpha/>","List-Post":"<mailto:libc-alpha@sourceware.org>","List-Help":"<mailto:libc-alpha-help@sourceware.org>,\n\t<http://sourceware.org/ml/#faqs>","Sender":"libc-alpha-owner@sourceware.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-1.9 required=5.0 tests=BAYES_00,\n\tRCVD_IN_DNSWL_NONE,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=","X-HELO":"mail-wr0-f169.google.com","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:subject:to:references:from:message-id:date\n\t:user-agent:mime-version:in-reply-to:content-transfer-encoding\n\t:content-language;\n\tbh=v81Bf85K+DMvMce92uAHHsmpU8hE2hvzjPpYCBQAsGA=;\n\tb=cMA2H0XSspSzGtV723dXO5RZtuRvQCu5nmKohW8pHquP/8PH7TczfMfX3lbxXZjJbK\n\tekbcN84azwlcuUqxJ5kUdZuHfBZ5tpiuQBhYML0LWrzs32czJnkoa/lnZDdIMg1pV0Pb\n\t+QrdeDQX+4gGBKDuhLZeUNTPuZeaERyS31b3FIW8tXlKld/+UI0JxzbCwIgw5LePHPO/\n\t64eLibCVsAsexybBKgZ81yztaOSep4lJT0x8LJtJE/B2sjQYifJErf2bkDTJtNBF9hiU\n\t5y0QVxNURRtXoAgDsmcI9thlPcFVHVn8eXzjkacNOLOOsG3iRfALT+pQ2qRIdFAXaS0A\n\tUEIA==","X-Gm-Message-State":"AHPjjUi8LNYOZHAyGhe+mvdkJNSNJuyEI4oEa7ADxAquPK7BdzC8Y5fL\n\tfwQXX1xvf0YHay4qLfO91Q==","X-Google-Smtp-Source":"ADKCNb6c7pdeM43KS49z6SBrn6foy4zymXKCBxBMqC2r/SzR0/F3yXAwauKkj3bP1jTrKxXsSDWv+g==","X-Received":"by 10.223.138.235 with SMTP id z40mr1418383wrz.14.1504862172800; \n\tFri, 08 Sep 2017 02:16:12 -0700 (PDT)","Subject":"Re: [PATCH 9/9] posix: Fix glob with GLOB_NOCHECK returning modified\n\tpatterns (BZ#10246)","To":"Paul Eggert <eggert@cs.ucla.edu>, libc-alpha@sourceware.org","References":"<1504643122-14874-1-git-send-email-adhemerval.zanella@linaro.org>\n\t<1504643122-14874-10-git-send-email-adhemerval.zanella@linaro.org>\n\t<2a8058e8-4859-d75b-a16d-7ea0dd61ffd7@cs.ucla.edu>","From":"Adhemerval Zanella <adhemerval.zanella@linaro.org>","Message-ID":"<caf37ff1-497f-a091-60af-ef813d71e888@linaro.org>","Date":"Fri, 8 Sep 2017 11:15:57 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.2.1","MIME-Version":"1.0","In-Reply-To":"<2a8058e8-4859-d75b-a16d-7ea0dd61ffd7@cs.ucla.edu>","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable"}}]