From patchwork Tue Jul 8 12:08:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1943 Received: (qmail 2516 invoked by alias); 8 Jul 2014 12:08:57 -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 2469 invoked by uid 89); 8 Jul 2014 12:08:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Date: Tue, 8 Jul 2014 17:38:46 +0530 From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Subject: [PATCH] Fix crash when system has no ipv6 address [BZ #17125] Message-ID: <20140708120846.GH609@spoyarek.pnq.redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.22.1-rc1 (2013-10-16) Hi, The test case bug-ga2 crashes when the system it is running on has no ipv6 address configured. This is because we point the cache (that is freed on exit) to a static variable if there is no ipv6 address, which later results in freeing an invalid pointer. Following patch fixes this crash. Siddhesh [BZ #17125] * sysdeps/unix/sysv/linux/check_pf.c (make_request): Allocate result using malloc. diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c index 1bc1def..063e15f 100644 --- a/sysdeps/unix/sysv/linux/check_pf.c +++ b/sysdeps/unix/sysv/linux/check_pf.c @@ -311,7 +311,8 @@ make_request (int fd, pid_t pid) atomic_add (&noai6ai_cached.usecnt, 2); noai6ai_cached.seen_ipv4 = seen_ipv4; noai6ai_cached.seen_ipv6 = seen_ipv6; - result = &noai6ai_cached; + result = malloc (sizeof (noai6ai_cached)); + memcpy (result, &noai6ai_cached, sizeof (noai6ai_cached)); } if (use_malloc)