From patchwork Tue Nov 21 13:55:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 119352 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp5124213edl; Tue, 21 Nov 2017 05:55:54 -0800 (PST) X-Google-Smtp-Source: AGs4zMYIJb2fd/Nnp6lk9LnbYVDYqnFHNR3eKEtnVi3k6t2ijRDURVPX5BLN0UNn7xlXzGMNAlGD X-Received: by 10.98.111.71 with SMTP id k68mr15278418pfc.91.1511272554477; Tue, 21 Nov 2017 05:55:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511272554; cv=none; d=google.com; s=arc-20160816; b=0olViuIf+6PY97oNXk73AlcnUowsxmtG5HfPABN3ETdUd+QMnX2FujeObnqPElYTNn 4ayL5RvFjx/1tunPho+0oiTA4gAUDR5gA/QBjbjWbolMy3DQ3xHyqpzVeJ9+FuGVHZ4Y Gvn79Yv2FeJv0zbGrD24DaJ4QTdMEClvEzuMt3ZlwDeGnAx+1uldp14PBte4xcgmO+xq ATk+pr/j+IqaT7x/3/B/g1L5DlavfORYceMtccOoGCv/G2OFCeNFEcaxfqWYq/ZXrQ8o yJeSphn1XJtPdZ03gKK2A5GwjGbvQtgwSVcUFqD+8684xcTP6nrcelXPQ2dfepjQn3Px hMgg== 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=f2OO1ll4KxaE7bnvpo3pDlNyCg9YZ/wV9BYoavbwMvk=; b=Ascld22hHzxdKrsm9wug1Qah3dyrh5eU+3UGaEPSIgxXsxqkFND+Fr5+GDBxOZPxFz DYYRWOpsmJGVKxEgqm/4k5GxpMGF+eIGxGPwlqYSo9U2BzdNx49d9oOfKxwExsu9oDv9 0G1ykM8FmqUoLHAxhJGJHZCJyKCoRe989mZS4kuj5e2cx9xjEBGE61tkzGzUrIE/82lH 67QOSuimssfT0gKW+DgtsRIfvJ2Pih7fY5HvKm8tOVRjilEVoFWPZSILTDj+COrbgpKa HxlxKma/nQK1No+NR8xXCIiJtacGYPHdXL08YRMLmMvgmJTDbRWbGYg48/g+5taStV+L w0wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=GStgw1rt; spf=pass (google.com: domain of libc-alpha-return-87356-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-87356-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 t63si5947755pgc.793.2017.11.21.05.55.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Nov 2017 05:55:54 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-87356-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=GStgw1rt; spf=pass (google.com: domain of libc-alpha-return-87356-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-87356-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=lvcTf/Vb/hGKKduEDJdAYW6VUaUZbKsKqWQuC0u6Ooh7/UwPigksp wQMEEnE020kBQ6PPVYoDjMd8I/lVKTx0Q6mro4+BFn2yV8gzInUHdXCJxi4OUW32 9wp4b3L1NT5LafH0Wt0swdH6123XcerZg2HGoygLUbS2IMqsaRSFCo= 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=iZQ2gAHEKSPJ8f7BK4woCOwfKmY=; b=GStgw1rtN5IoVlxg8zRAuRByr/un bj6lh7wcYCzWveIhMONTmkeEII3+dhPTPe8IFGc7uSOi3a1COZ7IrHN4K2Ui/uQs u21/6rrYuIglJKCRJhPD1CgB2kZ3dtqds2ypu+Kj5tr8tks5mBJ1KL9hS+/Z4ogt BdQcBiaFkyKKpuk= Received: (qmail 43775 invoked by alias); 21 Nov 2017 13:55:43 -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 43764 invoked by uid 89); 21 Nov 2017 13:55:42 -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, KB_WAM_FROM_NAME_SINGLEWORD, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=management X-HELO: mail-qk0-f196.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=f2OO1ll4KxaE7bnvpo3pDlNyCg9YZ/wV9BYoavbwMvk=; b=hbrbu7Aw01MJhT/WrIDJx//njrPeAdMAxI1h21ByeSd7LReyAh+Q7bqKofN1COeVmf iHpsY+qeJPIEocgFIGS/3O3p9H8ImicCcVmTmP8dPav/EMT/ZBsbQ7qpNCkgY/jmEcah 9jMODOJBC9IuzI5Sbo9bwjbDY6kfGse5m9v+s8Amx3GWG2IuYXHlxzI+/uSFllUYoMus TcB7OrIOSbZHmN2hm3rbxub1SUXxEx2Mga9cr3RWc9GWRKL9uEWMypjMsaV0pXM0actn YP3s6z02XKAguzzKy8rWH+fxndmnrZbGpXvRjy2nxZoY1PaJ4btR7xbfRPBoSLVc2fwE IDTg== X-Gm-Message-State: AJaThX74LmXOWk70jYDUtTjYd6bY2aogj2XcMWO6+N8rjv0FTZdWRlmM yUMmjOgMgPnL4LPIx2sAQSRUbNaX7Do= X-Received: by 10.55.73.87 with SMTP id w84mr14654744qka.215.1511272537426; Tue, 21 Nov 2017 05:55:37 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 0/8] posix: glob fixes and refactor Date: Tue, 21 Nov 2017 11:55:22 -0200 Message-Id: <1511272530-10936-1-git-send-email-adhemerval.zanella@linaro.org> This patchset main target is to remove alloca usage on glob by using a specialized dynarray for C strings (struct char_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). [1] http://lists.gnu.org/archive/html/bug-gnulib/2017-10/msg00056.html Adhemerval Zanella (8): 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 ChangeLog | 30 ++ malloc/Makefile | 4 +- malloc/Versions | 7 + malloc/char_array-impl.c | 57 ++++ malloc/char_array-skeleton.c | 279 +++++++++++++++++ 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/glob.c | 621 +++++++++++++++---------------------- 11 files changed, 837 insertions(+), 380 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