From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 86724 invoked by alias); 2 Nov 2018 09:48:53 -0000 Mailing-List: contact libc-stable-help@sourceware.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: List-Archive: Sender: libc-stable-owner@sourceware.org Received: (qmail 86379 invoked by uid 89); 2 Nov 2018 09:48:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.2 on sourceware.org 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,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=cherry, stdlib, xmalloc X-Spam-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 02 Nov 2018 09:48:26 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1380173A60 for ; Fri, 2 Nov 2018 09:48:15 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-117-198.ams2.redhat.com [10.36.117.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5DE7A5C1B2 for ; Fri, 2 Nov 2018 09:48:14 +0000 (UTC) Received: by oldenburg.str.redhat.com (Postfix, from userid 1000) id 13A4F4399457D; Fri, 2 Nov 2018 10:48:11 +0100 (CET) Date: Mon, 01 Jan 2018 00:00:00 -0000 To: libc-stable@sourceware.org Subject: [2.28 COMMITTED] Fix BZ#23400 (creating temporary files in source tree), and undefined behavior in test. User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20181102094811.13A4F4399457D@oldenburg.str.redhat.com> From: fweimer@redhat.com (Florian Weimer) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 02 Nov 2018 09:48:15 +0000 (UTC) X-IsSubscribed: yes X-SW-Source: 2018-11/txt/msg00000.txt.bz2 From: Paul Pluzhnikov (cherry picked from commit 6c3a8a9d868a8deddf0d6dcc785b6d120de90523) 2018-08-24 Paul Pluzhnikov [BZ #23400] * stdlib/test-bz22786.c (do_test): Fix undefined behavior, don't create temporary files in source tree. diff --git a/NEWS b/NEWS index f4d9885819..79b028008d 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,7 @@ Version 2.28.1 The following bugs are resolved with this release: [20209] localedata: Spelling mistake for Sunday in Greenlandic kl_GL + [23400] stdlib/test-bz22786.c creates temporary files in glibc source tree [23497] readdir64@GLIBC_2.1 cannot parse the kernel directory stream [23521] nss_files aliases database file stream leak [23538] pthread_cond_broadcast: Fix waiters-after-spinning case diff --git a/stdlib/test-bz22786.c b/stdlib/test-bz22786.c index e7837f98c1..d1aa69106c 100644 --- a/stdlib/test-bz22786.c +++ b/stdlib/test-bz22786.c @@ -26,28 +26,20 @@ #include #include #include +#include +#include +#include #include #include static int do_test (void) { - const char dir[] = "bz22786"; - const char lnk[] = "bz22786/symlink"; + const char *dir = support_create_temp_directory ("bz22786."); + const char *lnk = xasprintf ("%s/symlink", dir); + const size_t path_len = (size_t) INT_MAX + strlen (lnk) + 1; - rmdir (dir); - if (mkdir (dir, 0755) != 0 && errno != EEXIST) - { - printf ("mkdir %s: %m\n", dir); - return EXIT_FAILURE; - } - if (symlink (".", lnk) != 0 && errno != EEXIST) - { - printf ("symlink (%s, %s): %m\n", dir, lnk); - return EXIT_FAILURE; - } - - const size_t path_len = (size_t) INT_MAX + 1; + TEST_VERIFY_EXIT (symlink (".", lnk) == 0); DIAG_PUSH_NEEDS_COMMENT; #if __GNUC_PREREQ (7, 0) @@ -55,20 +47,14 @@ do_test (void) allocation to succeed for the test to work. */ DIAG_IGNORE_NEEDS_COMMENT (7, "-Walloc-size-larger-than="); #endif - char *path = malloc (path_len); + char *path = xmalloc (path_len); DIAG_POP_NEEDS_COMMENT; - if (path == NULL) - { - printf ("malloc (%zu): %m\n", path_len); - return EXIT_UNSUPPORTED; - } - - /* Construct very long path = "bz22786/symlink/aaaa....." */ - char *p = mempcpy (path, lnk, sizeof (lnk) - 1); + /* Construct very long path = "/tmp/bz22786.XXXX/symlink/aaaa....." */ + char *p = mempcpy (path, lnk, strlen (lnk)); *(p++) = '/'; - memset (p, 'a', path_len - (path - p) - 2); - p[path_len - (path - p) - 1] = '\0'; + memset (p, 'a', path_len - (p - path) - 2); + p[path_len - (p - path) - 1] = '\0'; /* This call crashes before the fix for bz22786 on 32-bit platforms. */ p = realpath (path, NULL); @@ -81,7 +67,6 @@ do_test (void) /* Cleanup. */ unlink (lnk); - rmdir (dir); return 0; }