From patchwork Sun Oct 22 08:09:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 829004 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-86251-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="jasUgAGC"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yKXJM5TDPz9rxm for ; Sun, 22 Oct 2017 19:09:55 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:to:subject:mime-version:content-type :content-transfer-encoding:message-id:from; q=dns; s=default; b= RDKai2OYmdVBn+dJqTChfMYBR/YErykTX+tOJdpWIVGTXPI1pgpnngxOWfK9pN+r +E+k0Wsh7NQ4Xay21Z4nGGZdl2oREfZ+b8zTa14WzsI0zcgoKK2c5QOl4BCd99uT VFR9VCn4HQ1arketDkc/BFfHnHRJRX0v22o1oIyo7Og= 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:date:to:subject:mime-version:content-type :content-transfer-encoding:message-id:from; s=default; bh=07t8C4 cAdbajOmRqSf77w75Ec/E=; b=jasUgAGCbBjJUj/UPJgFg2TQB3sVOod94Q4vaR c/kyTKXRnuVyFGaVxJmPNnDnaMxl0iw6D9Ii2xZQ/FZ4RoaQnCqsWFmjAXg5Wagj VRaaxBk0bSjG56vCNi96rDnL5D1ejW+fkvAMpl9XYLvQezgZUNhBfi6fwe8RdvAR vzAb4= Received: (qmail 104411 invoked by alias); 22 Oct 2017 08:09:49 -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 102627 invoked by uid 89); 22 Oct 2017 08:09:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 600C081DE4 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=fweimer@redhat.com Date: Sun, 22 Oct 2017 10:09:43 +0200 To: libc-alpha@sourceware.org Subject: [PATCH] posix/tst-glob-tilde.c: Add test for bug 22332 User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Message-Id: <20171022080943.B750342843A00@oldenburg.str.redhat.com> From: fweimer@redhat.com (Florian Weimer) 2017-10-22 Florian Weimer [BZ #22332] * posix/tst-glob-tilde.c (do_noescape): New variable. (one_test): Process it. (do_test): Set do_noescape. Add unescaping test case. diff --git a/posix/tst-glob-tilde.c b/posix/tst-glob-tilde.c index 9518b4a6f8..6886f4371f 100644 --- a/posix/tst-glob-tilde.c +++ b/posix/tst-glob-tilde.c @@ -1,4 +1,4 @@ -/* Check for GLOB_TIDLE heap allocation issues (bug 22320, bug 22325). +/* Check for GLOB_TIDLE heap allocation issues (bugs 22320, 22325, 22332). Copyright (C) 2017 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -34,6 +34,9 @@ static int do_nocheck; /* Flag which indicates whether to pass the GLOB_MARK flag. */ static int do_mark; +/* Flag which indicates whether to pass the GLOB_NOESCAPE flag. */ +static int do_noescape; + static void one_test (const char *prefix, const char *middle, const char *suffix) { @@ -45,6 +48,8 @@ one_test (const char *prefix, const char *middle, const char *suffix) flags |= GLOB_NOCHECK; if (do_mark) flags |= GLOB_MARK; + if (do_noescape) + flags |= GLOB_NOESCAPE; glob_t gl; /* This glob call might result in crashes or memory leaks. */ if (glob (pattern, flags, NULL, &gl) == 0) @@ -105,28 +110,30 @@ do_test (void) for (do_onlydir = 0; do_onlydir < 2; ++do_onlydir) for (do_nocheck = 0; do_nocheck < 2; ++do_nocheck) for (do_mark = 0; do_mark < 2; ++do_mark) - for (int base_idx = 0; base_sizes[base_idx] >= 0; ++base_idx) - { - for (int size_skew = -max_size_skew; size_skew <= max_size_skew; - ++size_skew) - { - int size = base_sizes[base_idx] + size_skew; - if (size < 0) - continue; + for (do_noescape = 0; do_noescape < 2; ++do_noescape) + for (int base_idx = 0; base_sizes[base_idx] >= 0; ++base_idx) + { + for (int size_skew = -max_size_skew; size_skew <= max_size_skew; + ++size_skew) + { + int size = base_sizes[base_idx] + size_skew; + if (size < 0) + continue; - const char *user_name = repeating_string (size); - one_test ("~", user_name, "/a/b"); - } + const char *user_name = repeating_string (size); + one_test ("~", user_name, "/a/b"); + one_test ("~", user_name, "x\\x\\x////x\\a"); + } - const char *user_name = repeating_string (base_sizes[base_idx]); - one_test ("~", user_name, ""); - one_test ("~", user_name, "/"); - one_test ("~", user_name, "/a"); - one_test ("~", user_name, "/*/*"); - one_test ("~", user_name, "\\/"); - one_test ("/~", user_name, ""); - one_test ("*/~", user_name, "/a/b"); - } + const char *user_name = repeating_string (base_sizes[base_idx]); + one_test ("~", user_name, ""); + one_test ("~", user_name, "/"); + one_test ("~", user_name, "/a"); + one_test ("~", user_name, "/*/*"); + one_test ("~", user_name, "\\/"); + one_test ("/~", user_name, ""); + one_test ("*/~", user_name, "/a/b"); + } free (repeat);