From patchwork Mon Feb 5 13:27:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 126875 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1971072ljc; Mon, 5 Feb 2018 05:27:56 -0800 (PST) X-Google-Smtp-Source: AH8x227Ddv2JhAsPc/xgsIKvtrG5EeBoeGmp2187HOxRKKYFYcHvVE63uZj8ovMxFFyUAC1Nsxyi X-Received: by 2002:a17:902:49:: with SMTP id 67-v6mr43019225pla.424.1517837276348; Mon, 05 Feb 2018 05:27:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517837276; cv=none; d=google.com; s=arc-20160816; b=auhgZFT585uSgyyYWeAFL7un+fim189LM6Qp4SU/Vpgi3Qr1UVJsKOrZcgR/PxD4DL A6mUTLnAuCYV4kktAE5uWmQu9Ny4PyvANq+H4xmxDT6kFqXO/c6gqfXhjy/g5zjLb4LZ gEEgb8WrNWpq/UXL7+TX6AeS0og7nmfr7wofMiVQpHWk4ow1jkYv/KhvsqJF2P3l7DQa SZHa6RZ5W00AxCYHm9/FpRZuUCxCfg2s+Rd00fBFCx6UCMPhbhsGtXmnuOxkL4LivJ8s bg4Tm6BTESBLClkpMb6l/RqnRlM3ZtmTqrbCu1obFTwWfQWd0gWG5gkSzD94sxftjliN BxkA== 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=zLneWmIUxKvxhhs232OGnUikQACSx3OWFE7cG86dmKE=; b=xLqiPOqcs8jC0vpFV1gsgrCB526YUeE+3sHHetjeW8RurHYNUJbGoe0Ks4Vo95jKRh PDQtLE5LQWMGyzOCI5QY9aBH+PcsNdG0QoylYotKN9RYKbQCb+4ARwXpPkNmVAY77n3Z x5NC7XewDm7v1Hzs62w01ZbyeSr1SiM5VvSa8kc87zZUtTD/cd3OeSLLiWwSCXXlzUaC 6yHDMRIclDVlXND3M/5Ez8Eznnzk1ntfbCYYsRiveloyrcmxMrmCWN9vcWqiFh0+Ws3r 1vDY81kk8XqPILP3yHC0stWIsgJ7nEd5p9rkdxtcmDAkAJW4EqYlAtDPJivTIneX0HP/ L3Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=O+QjcPaT; spf=pass (google.com: domain of libc-alpha-return-89964-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-89964-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 l4-v6si7027786plk.390.2018.02.05.05.27.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 05:27:56 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-89964-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 header.s=default header.b=O+QjcPaT; spf=pass (google.com: domain of libc-alpha-return-89964-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-89964-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=Y3q8GMqO5WDopUYGtrSeQS6QGXYoPN16lhS9uOC6HydqcU0CIbD6p +1S2bXauNaqcTQDXJvSAUegL3T57i5JVkBJVMwOu13iTo9BbxbKhP9LzCL18VSV/ n10+aiOnimM47S2rowbdNrnkhbvyfqTUmFRSZJz0V8LVaTXfT4jSoY= 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=hVvfVzde0IDaZk1JKXjeu4QPyKs=; b=O+QjcPaTqM865Jjd5hywidHeKl4N JJZgAd6O5ZrBt/qxUGUsjpD0giLbeIaRY3OdyTJEXLg4jgFi0NMRrRpjdhvYgPyV 2wFAmlpZlAuMkr0AHOeo6ESK2B4pdONMUZFv8aMYsQxGgfFOW3xtRgqW/mPQdK77 dBZoGBmOks8LheI= Received: (qmail 31846 invoked by alias); 5 Feb 2018 13:27:46 -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 31835 invoked by uid 89); 5 Feb 2018 13:27:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-12.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=vla, management X-HELO: mail-qt0-f173.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=zLneWmIUxKvxhhs232OGnUikQACSx3OWFE7cG86dmKE=; b=gH0ii5ShKM00nk9LPS2OtXyIO+fDukiNDxDEpBeJjmdj4M/DfC6VMLQ6GBq7v5bs7F 05Qan8qZIZwTrNMH89bl2PKRCV3xrsCsQb7Dwlcat27lo7gxq6X1k//xTpj1uotZ7hds 6IUZRmLhJHlIMBZT6oSQzTA9Wk82z87J4LPDCWD4N7n/j/8DDqYoeJ0PY+5Oi3u5mohd 0DIw/YJ2ORK+EUH2fP7KuJ2v511yZbZauN+sP/0k+3s58dRNMbWNV1KeU7HSrT8vHZDD IjS2THxqAEo5b2cKPyqblL+ekvnLax+XVcvMrqJebCe1cjUV2Xg40LqiGZCyaP7XiHAa Pm7g== X-Gm-Message-State: APf1xPAEL24K667caMFgLImSkgitr/c4ACfzTi6C1pfyC249dSnNLLoH EmazvWlLVDK4rFmcDMIAqA9KQUBMuQ8= X-Received: by 10.200.36.37 with SMTP id c34mr1707416qtc.253.1517837261802; Mon, 05 Feb 2018 05:27:41 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 00/12] posix: glob/fnmatch fixes and refactor Date: Mon, 5 Feb 2018 11:27:22 -0200 Message-Id: <1517837254-19399-1-git-send-email-adhemerval.zanella@linaro.org> This patchset main target is to remove alloca usage on glob and fnmatch by using a specialized dynarray for C strings (struct char_array) along with already in place scratch_buffer and dynamic_array. It does not change any glob semantics, only internal glob buffer management. It also does not solve the potential stack overflow due recursive allocation from wildcard in patterns [1] (although an option would be go to pure dynamic char_array for this case). I have added the fnmatch and getlogin_r on this series because glob uses them internally. [1] http://lists.gnu.org/archive/html/bug-gnulib/2017-10/msg00056.html Adhemerval Zanella (11): malloc: Add specialized dynarray for C strings posix: Use char_array for internal glob dirname 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 alloca usage on glob user_name posix: Use char_array for home_dir in glob posix: Remove all alloca usage in glob posix: Replace alloca usage with scratch_buffer for fnmatch posix: Remove alloca usage for internal fnmatch implementation posix: Remove VLA usage for internal fnmatch implementation Florian Weimer (1): getlogin_r: switch Linux variant to struct scratch_buffer ChangeLog | 47 +++ malloc/Makefile | 4 +- malloc/Versions | 7 + malloc/char_array-impl.c | 57 ++++ malloc/char_array-skeleton.c | 288 ++++++++++++++++ malloc/char_array.h | 53 +++ malloc/dynarray.h | 9 + malloc/dynarray_overflow_failure.c | 31 ++ malloc/malloc-internal.h | 14 + malloc/tst-char_array.c | 112 +++++++ posix/fnmatch.c | 143 ++------ posix/fnmatch_loop.c | 230 +++++++------ posix/glob.c | 624 ++++++++++++++--------------------- sysdeps/unix/sysv/linux/getlogin_r.c | 34 +- 14 files changed, 1015 insertions(+), 638 deletions(-) create mode 100644 malloc/char_array-impl.c create mode 100644 malloc/char_array-skeleton.c create mode 100644 malloc/char_array.h create mode 100644 malloc/dynarray_overflow_failure.c create mode 100644 malloc/tst-char_array.c -- 2.7.4