From patchwork Thu Jun 8 21:13:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 103405 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp2632169qgd; Thu, 8 Jun 2017 14:13:58 -0700 (PDT) X-Received: by 10.84.212.137 with SMTP id e9mr37302736pli.115.1496956438802; Thu, 08 Jun 2017 14:13:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496956438; cv=none; d=google.com; s=arc-20160816; b=HOVr6AZOlM8v4qZsEbWl/OU9C9nWxIYHIa8ZRw6bHGevOHrgBCH/YnJLlX514j0o5V N3hbVe2sjNvKGbowUgM4soONE0D5N/m3Ua85i7SZOmJM6Y50cOdNe3fqXbCyUU+pv5bE Ck4koNXSLWwCtmIBj63g6/oIidD17DdDQqbnwJRSyOdOVN8NAT0sQKIbeSWy/Ti/9dTF qLLC+Egc29YxCTxESziC4VkzaxKAWBMlWOLTAF6xGUZJWJAYKBaaGXrER8qz5RaLD/UO ui9EzeMkXmlP5Hi1wc2JOih0qaTustF3fzlski4IKOYofxryTwxrp9QsQH9grC0O9mkL LvHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=XrfSekBvOOLJfKBWD1X3W7fC2c2ELR6egKtH2trwmFY=; b=gPdgrXcKLpfI9zctfLudAlMpAjeQEXksrnCpZS4Zx+h8IESp0GfhEydDb/6KWdrqlr kZuASzED1zg/WQa1gom2MzXqGmr8xUSo81rEpuEmb9KePL0d1kQgK0xUL2WLFWCvjAQU 8Odzw736T3Zvf082qdtdQPS4zTK2rQP6xfGRUOjzeFxzv8NnMQJ1tBjOqcO8sB/DUdAv bUyY2owE/lmBXYJ0ddbvNifD8DFcnFIe16MF6ayHv+R38Kgoq6ekIPJG7vbQtNu6ya3c hD7orf8hR2aOQZ8H1FanWOr8qcrTNFB8b3zyuP0dokoq0tugHFbYo6EAwfBzAFQGPTJU ZEZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of libc-alpha-return-80199-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-80199-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id p77si1939482pfj.399.2017.06.08.14.13.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jun 2017 14:13:58 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-80199-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of libc-alpha-return-80199-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-80199-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; q=dns; s= default; b=RdQUtDQQUGDkAztf58x57krszZ9AKTvXF0gX9yIWdGy8JS61wwkeq oTXGCpO+NM38eFqsrU/mwWFuIWCPwOWnLJ/o0TawvDoD9R25qk7NI1K9gyb3joc4 oW4BkWhhYN2oyqNfkf4Ac5KfimfZIe3ysJ5//dwFcB1H27tFF4ZLdk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; s=default; bh=ZyBe+NICjGtkEEEdZ58sIQCFErw=; b=RYsOlTaM77r85uGDLv1dPjbzHfV3 pwx7GxPiiwyxUE34Twtj7fPTyhut5nSHqE1myE0GaGZ3+5yrmXJ2tzUs59TqTr3G BFG1edS5X6OtXvARJEt7usdRaaiWBFPjQYyaYBq/rOpY+abt3y4ZUDHmMaOWxXy+ 1A1bC9ysrYJ9wos= Received: (qmail 36812 invoked by alias); 8 Jun 2017 21:13:42 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 36800 invoked by uid 89); 8 Jun 2017 21:13:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-9.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, UNSUBSCRIBE_BODY autolearn=ham version=3.3.2 spammy=standing X-HELO: mail-qt0-f171.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=XrfSekBvOOLJfKBWD1X3W7fC2c2ELR6egKtH2trwmFY=; b=hBudv7/wDtaL61+ObaCs7Dqh7B1Ai9P88FHJfE5Pk/LFd8RCntAtwrPV/2HDm1edBr CKaaSgCSU6VttIk1mBHYy7+9myvRKl1nCDf1cbWOpjnmjHVqd6JAXbzBZWwbhB3Vr8GI gqxVTIDyYe7EixlsGbLN9o1xC2tUPi0a0ROxTF/4H6yCTcf0QGniAfLsYiMiZuIEUl3b MBx3erkpfFkhTtWfDwdjxnofFlqPk0ZDpK8UTN7j5HSbcaKBNLQlv8lnM/rjonWe9JWH 5Ggxd4QbRznkDnoQ7CZaFteWqE0lFOuyLZP8SM2DyXpowPy+lM0yQviW44cDofSUXMw2 ImEA== X-Gm-Message-State: AKS2vOy1CrdeclA7VYEQ8xumqLJHmXC6bPJTPE3XT2eCeaqppI0IX0AA XHuxl0Dt3V6idLWdwR+Pfg== X-Received: by 10.55.90.196 with SMTP id o187mr44871108qkb.113.1496956422035; Thu, 08 Jun 2017 14:13:42 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 00/17] posix: glob fixes and refactor Date: Thu, 8 Jun 2017 18:13:14 -0300 Message-Id: <1496956411-25594-1-git-send-email-adhemerval.zanella@linaro.org> The set fixes some long standing glob issues (gnulib sync and dandling symlinks) the refactor current, adjust its tests for libsupport and refactor current implementation to use a dynarray implementation for C strings. To correct provide a C string analogous using dynarray I had to access its private member directly, so I created a specialized implementation (malloc/char_array.c) for it. It currently works similar to dynarray, by including its header which defines static functions. If it is the case, one could its function as an internal API. I added some function only to manipulate mainly for the work to refactor glob. The idea to refactor is mainly to remove the alloca and internal buffer handling boilerplate usage. So it does not trace its possible stack usage using 'alloca_used' variable, which is somewhat fragile (since it just track glob usage itself). I used 256 bytes for default string size (for initial stack allocation), but we can also tune it if required. I did not and will not take care of the non-unix code on glob.c (it is probably broken after the glob refactor). In fact I would like to cleanup this implementation even further to remove all code not really used for GLIBC if gnulib developers want to not keep the implementation at sync. Adhemerval Zanella (16): posix: Sync glob with gnulib [BZ #1062] posix: Allow glob to match dangling symlinks [BZ #866] support: Add optstring support posix: Adjust glob tests to libsupport posix: Consolidate glob implementation malloc: Add specialized dynarray for C strings posix: Use char_array for internal glob dirname posix: Remove glob GET_LOGIN_NAME_MAX usage posix: User LOGIN_NAME_MAX for all user name in glob posix: Remove alloca usage for GLOB_BRACE on glob posix: Remove alloca usage on glob dirname posix: Use dynarray for globname in glob posix: Remove all alloca usage in glob posix: Use char_array for home_dir in glob posix: Add common function to get home directory posix: More check for overflow allocation in glob Florian Weimer (1): posix: Rewrite to use struct scratch_buffer instead of extend_alloca malloc/Makefile | 1 + malloc/char_array.c | 256 +++++ malloc/malloc-internal.h | 14 + malloc/tst-char_array.c | 107 ++ posix/Makefile | 17 +- posix/bug-glob1.c | 88 -- posix/bug-glob3.c | 45 - posix/glob.c | 1166 ++++++++------------ posix/glob_internal.h | 57 + posix/glob_pattern_p.c | 29 + posix/globfree.c | 37 + posix/globfree64.c | 27 + posix/globtest.c | 166 +-- posix/tst-glob_basic.c | 41 + posix/tst-glob_common.c | 103 ++ posix/{bug-glob2.c => tst-glob_memory.c} | 100 +- posix/tst-glob_symlinks.c | 133 +++ posix/tst-gnuglob.c | 109 +- support/support_test_main.c | 3 +- support/test-driver.c | 9 + support/test-driver.h | 1 + sysdeps/gnu/glob64.c | 25 - sysdeps/unix/sysv/linux/Makefile | 2 +- sysdeps/unix/sysv/linux/alpha/Makefile | 4 - sysdeps/unix/sysv/linux/alpha/{glob.c => glob64.c} | 11 - sysdeps/unix/sysv/linux/alpha/globfree.c | 36 + sysdeps/unix/sysv/linux/arm/glob64.c | 1 - sysdeps/unix/sysv/linux/glob.c | 23 + sysdeps/unix/sysv/linux/glob64.c | 55 + sysdeps/unix/sysv/linux/globfree.c | 23 + sysdeps/unix/sysv/linux/globfree64.c | 0 sysdeps/unix/sysv/linux/i386/alphasort64.c | 2 +- sysdeps/unix/sysv/linux/i386/getdents64.c | 2 +- sysdeps/unix/sysv/linux/i386/readdir64.c | 2 +- sysdeps/unix/sysv/linux/i386/readdir64_r.c | 2 +- sysdeps/unix/sysv/linux/i386/versionsort64.c | 2 +- sysdeps/unix/sysv/linux/m68k/glob64.c | 1 - sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c | 1 - sysdeps/unix/sysv/linux/{i386 => }/olddirent.h | 0 .../unix/sysv/linux/{i386/glob64.c => oldglob.c} | 51 +- sysdeps/unix/sysv/linux/powerpc/powerpc32/glob64.c | 1 - sysdeps/unix/sysv/linux/s390/s390-32/glob64.c | 20 + sysdeps/unix/sysv/linux/s390/s390-32/oldglob.c | 2 + sysdeps/unix/sysv/linux/sparc/sparc32/glob64.c | 1 - sysdeps/unix/sysv/linux/wordsize-64/glob64.c | 2 - sysdeps/unix/sysv/linux/x86_64/x32/glob.c | 1 - sysdeps/wordsize-64/glob.c | 8 - sysdeps/wordsize-64/glob64.c | 1 - 48 files changed, 1558 insertions(+), 1230 deletions(-) create mode 100644 malloc/char_array.c create mode 100644 malloc/tst-char_array.c delete mode 100644 posix/bug-glob1.c delete mode 100644 posix/bug-glob3.c create mode 100644 posix/glob_internal.h create mode 100644 posix/glob_pattern_p.c create mode 100644 posix/globfree.c create mode 100644 posix/globfree64.c create mode 100644 posix/tst-glob_basic.c create mode 100644 posix/tst-glob_common.c rename posix/{bug-glob2.c => tst-glob_memory.c} (76%) create mode 100644 posix/tst-glob_symlinks.c delete mode 100644 sysdeps/gnu/glob64.c rename sysdeps/unix/sysv/linux/alpha/{glob.c => glob64.c} (78%) create mode 100644 sysdeps/unix/sysv/linux/alpha/globfree.c delete mode 100644 sysdeps/unix/sysv/linux/arm/glob64.c create mode 100644 sysdeps/unix/sysv/linux/glob.c create mode 100644 sysdeps/unix/sysv/linux/glob64.c create mode 100644 sysdeps/unix/sysv/linux/globfree.c create mode 100644 sysdeps/unix/sysv/linux/globfree64.c delete mode 100644 sysdeps/unix/sysv/linux/m68k/glob64.c delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c rename sysdeps/unix/sysv/linux/{i386 => }/olddirent.h (100%) rename sysdeps/unix/sysv/linux/{i386/glob64.c => oldglob.c} (62%) delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/glob64.c create mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/glob64.c create mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/oldglob.c delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/glob64.c delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/glob64.c delete mode 100644 sysdeps/unix/sysv/linux/x86_64/x32/glob.c delete mode 100644 sysdeps/wordsize-64/glob.c delete mode 100644 sysdeps/wordsize-64/glob64.c -- 2.7.4