From patchwork Tue Nov 21 13:55:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 119360 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp5125486edl; Tue, 21 Nov 2017 05:57:14 -0800 (PST) X-Google-Smtp-Source: AGs4zMaLNalF/wS5lidt+q6SjtUw19C3YLXs6nxI4RsqWAxsy5pbBVDTKnsqEaCLLPqtn5gmf3s2 X-Received: by 10.159.207.149 with SMTP id z21mr18189062plo.164.1511272634636; Tue, 21 Nov 2017 05:57:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511272634; cv=none; d=google.com; s=arc-20160816; b=0zRlWLCC5GGXyMDCelAg7+qpSvdUGWGAWDietfoCoaxQ9W1KmRUhEkQFyQK2Cht1SO SwfN5prlwQ/u/hViKr3XzZi/lTIqn0BDc+x5B3ir3wU1Hdc2FVq5S0Q0Wh5bWC39m/Dh 3uT3gdCtTxDV0ukf18kp54Pceo4Y/XHirx+f5VihROx7Mc+MBydg1xXlARlxZGuLCsgU TQv8NXmT4cVR3mSPyQW+72Tmx7Dyfdoh1mkQEI+icjYbc9qcB6T8fLorXsNaenSqg5OP 5Bq7rhfUWmGeVRvEWjjIdu1i5fX5wGxNVMLaKIMbGrOLFUDneHrj1Cm2/Fax6QUDxh35 lC6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to: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=mqznf0jFwl3abYRv57lLdH9MckAo8tbCE27iiDmt/Ck=; b=hYv6uvUAkz0uNn60GYJQTq9gnvX2Hfz2Ff+HK7O1B1oPcohE2M6Wp/Y3VUNkqCZkf2 mh1pDRhxeaIGJRpEOJWH4uLmZHVLNRYXSkuNLUOXHDfFaVmbZGaI7InZu5NXxETbYt0Q SSt1VB/fd0YPIUf5sfQ1PZnte02AM8peoIV2JVgxt8WRU+x8LzUv/cihoNYxtEfvKY7H m/z+JxyWa/AGYj13FC++fWvm/42EYTC3XQPC1iQKBhB3eqlVQbZQdnYcgeg1jveMmxaO BK7KdirWGXVbfsegT6Ni+gfrgkJ4LcN1TYGvK7L6SgdcBxa5IHGPPWecH3DVWb9WoCuc xabQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=JXeh0S6Z; spf=pass (google.com: domain of libc-alpha-return-87364-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-87364-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 w9si9769411plp.333.2017.11.21.05.57.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Nov 2017 05:57:14 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-87364-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=JXeh0S6Z; spf=pass (google.com: domain of libc-alpha-return-87364-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-87364-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:in-reply-to :references; q=dns; s=default; b=u0j9H2owVKdxC5wAfFA80pdW27FiwqC T7hUZmC2HagZepzceU7Yontd6A1x+TlAM2MGQuTxEAc02DrizNG90Bk0aMVhvs7U OS7784QpgZKErxGilj06MiwHz7M77hCt0RM9c28KTCuaQjOcjtUw26e0GIY7/tMl MIq3XYct5GzU= 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:in-reply-to :references; s=default; bh=fo1uPMAudU5cvguA1TYCkr9zpwc=; b=JXeh0 S6ZFlkaZHCbTJ6foLq95M69cI1nbz9UCt9lBYVjaxg2JpRIvVk1eqTvNr9OCfkIL kbDr5LOMQu4v211zmGPcQ5F6z9DUNaewwiI3jbk+SJxWUpoGiSii2W6jDbmeppGQ WMFKz4+YSarKb+jdJ/rOvPZOIuhsW6+EcYxnd4= Received: (qmail 45183 invoked by alias); 21 Nov 2017 13:55:52 -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 45162 invoked by uid 89); 21 Nov 2017 13:55:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=1706, fname 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:in-reply-to :references; bh=mqznf0jFwl3abYRv57lLdH9MckAo8tbCE27iiDmt/Ck=; b=F/AkhYM95arz1EvCSEPapWGJp/ZT/1RsFzBwxD2jnwDySlJT2tBsqjOTOBryDSEcoz 6riPZG7fWr6R/eWmrdHa2PSbL8AVsi67P510h8mt6mdb/vLNt4LCSHagSQ2/Cm7OD986 AcPcNQjiEtj5U871YDJI9op3IDG9fWEAclKxnQTIPd/MTwmT2yA+ojcAoSfbo9LUUwxR Yc42DkEvfsvf1C9pecisH4oFS2i2xenqwKnIU9uNVfMj0GF39OuBcyiUwnBgABUNVjBT FCR/ehk9m+L6t7j/GXST4mG0Xdw32wljKCflevgYQtaSxg/XC1QXB76ej+5g3L3Zys59 htKg== X-Gm-Message-State: AJaThX4exWsOVpktjt2Pn1zyRAOUDyaHgFHcMIIjEwia8BzOf1NFAsqn a7SVPDiGnv75V1o98Uq7bjlvDlsfwKk= X-Received: by 10.55.58.14 with SMTP id h14mr24670842qka.132.1511272548598; Tue, 21 Nov 2017 05:55:48 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 8/8] posix: Remove all alloca usage in glob Date: Tue, 21 Nov 2017 11:55:30 -0200 Message-Id: <1511272530-10936-9-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1511272530-10936-1-git-send-email-adhemerval.zanella@linaro.org> References: <1511272530-10936-1-git-send-email-adhemerval.zanella@linaro.org> With alloca usage removal from glob this patch wraps it up by removing all the alloca defines and macros usage. Checked on x86_64-linux-gnu. * posix/glob.c (glob_in_dir, glob): Remove alloca_used argument. Signed-off-by: Adhemerval Zanella --- ChangeLog | 2 ++ posix/glob.c | 25 ++++++++----------------- 2 files changed, 10 insertions(+), 17 deletions(-) -- 2.7.4 diff --git a/posix/glob.c b/posix/glob.c index 71807d6..4d40c4c 100644 --- a/posix/glob.c +++ b/posix/glob.c @@ -32,7 +32,6 @@ #ifndef WINDOWS32 # include -# include #endif #include @@ -65,9 +64,6 @@ # define __stat64(fname, buf) stat (fname, buf) # define __fxstatat64(_, d, f, st, flag) fstatat (d, f, st, flag) # define struct_stat64 struct stat -# ifndef __MVS__ -# define __alloca alloca -# endif # define __readdir readdir # define COMPILE_GLOB64 #endif /* _LIBC */ @@ -174,12 +170,6 @@ convert_dirent64 (const struct dirent64 *source) # ifdef GNULIB_defined_closedir # undef closedir # endif - -/* Just use malloc. */ -# define __libc_use_alloca(n) false -# define alloca_account(len, avar) ((void) (len), (void) (avar), (void *) 0) -# define extend_alloca_account(buf, len, newlen, avar) \ - ((void) (buf), (void) (len), (void) (newlen), (void) (avar), (void *) 0) #endif static int @@ -207,7 +197,7 @@ glob_lstat (glob_t *pglob, int flags, const char *fullname) static int glob_in_dir (const char *pattern, const char *directory, int flags, int (*errfunc) (const char *, int), - glob_t *pglob, size_t alloca_used); + glob_t *pglob); static int prefix_array (const char *prefix, char **array, size_t n) __THROWNL; static int collated_compare (const void *, const void *) __THROWNL; @@ -273,7 +263,6 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), bool dirname_modified; glob_t dirs; int retval = 0; - size_t alloca_used = 0; struct char_array dirname; if (pattern == NULL || pglob == NULL || (flags & ~__GLOB_FLAGS) != 0) @@ -520,11 +509,13 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), char *drive_spec; ++dirlen; - drive_spec = __alloca (dirlen + 1); + drive_spec = malloc (dirlen + 1); *((char *) mempcpy (drive_spec, pattern, dirlen)) = '\0'; /* For now, disallow wildcards in the drive spec, to prevent infinite recursion in glob. */ - if (__glob_pattern_p (drive_spec, !(flags & GLOB_NOESCAPE))) + int r = __glob_pattern_p (drive_spec, !(flags & GLOB_NOESCAPE)); + free (drive_spec); + if (r != 0) { retval = GLOB_NOMATCH; goto out; @@ -920,7 +911,7 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), status = glob_in_dir (filename, dirs.gl_pathv[i], ((flags | GLOB_APPEND) & ~(GLOB_NOCHECK | GLOB_NOMAGIC)), - errfunc, pglob, alloca_used); + errfunc, pglob); if (status == GLOB_NOMATCH) /* No matches in this directory. Try the next. */ continue; @@ -1025,7 +1016,7 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), if (dirname_modified) flags &= ~(GLOB_NOCHECK | GLOB_NOMAGIC); status = glob_in_dir (filename, char_array_str (&dirname), flags, - errfunc, pglob, alloca_used); + errfunc, pglob); if (status != 0) { if (status == GLOB_NOMATCH && flags != orig_flags @@ -1190,7 +1181,7 @@ struct globnames_result static int glob_in_dir (const char *pattern, const char *directory, int flags, int (*errfunc) (const char *, int), - glob_t *pglob, size_t alloca_used) + glob_t *pglob) { void *stream = NULL; struct globnames_array globnames;