From patchwork Tue Dec 19 18:03:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 122405 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4488522qgn; Tue, 19 Dec 2017 10:04:17 -0800 (PST) X-Google-Smtp-Source: ACJfBoumdu4sKazkr6z9plnuoBrC0PsIEsbP82+i/3aFMPwORe6c/zaUwtU8aTqIgibW4W/5JOHs X-Received: by 10.98.93.210 with SMTP id n79mr4099340pfj.215.1513706657490; Tue, 19 Dec 2017 10:04:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513706657; cv=none; d=google.com; s=arc-20160816; b=fXWHPJZ1zb9Lp86MRSGMUCXk55RSOXDZadGrJVAfbA9IYjbE4PF79URv1sGAu5Ym8Y 9cn85T5VP14tyGp2nsjxAGK6oa1lMm4690c6ryCaKUoYQgALCHi9BOuz0WqxWKPV/n3n FqWMukTK0u1mWHpQph4pM9y5v/jCSeEZPnytgaPkTMtFtMgRy3i0GGdhqnAK4stfvpPO ZiuEC+LOYy2u5Vp9J+DyLoMPjWl07cIpYX8dGWg3TnozsqQseWIQSJie7WipdHqBgMvc Zd3FhIcTH7Yhfj8FzGOAH5boERhKx2nFEdG33Fao0egd8A3ywDjAfLF6RYFty8Z1Zcbi 3Zgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version: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=Vb0UjslSNKcGbLhzoQadW9AIB6q2Bm9ad+YLJ6MVqzA=; b=IjxZx+pWFaCemacW9eU24w5H6A+ZGhiVfWg+G1hjaQhJhuMAgIT3q+OIuMvRTY/sCr odJfvfaNf19WsAuSJ9xt2EypHx1R16xUAX5AslqbBRHKM+kcFSET5d1fwyyBin7nevU5 tpi+npdv6LG5lu4j0zltvmTLCRB560qQJjH0QTMiO6d8DRPZNegRW9q69cIgWEolJLjN pvraeZYv6VSw+Wwns2PDi5ecBK/jr+bfzxYGDAfATrDw+MdnUjWJmr1XtuDTaPKhCuLH hgq9BXsddkU9Kp36v4S2O1LyTxfe8CbreTCpurBFqSSB2+SG79lioW4tAYjxslLC32Cr juYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=qk/CpqCb; spf=pass (google.com: domain of libc-alpha-return-88355-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-88355-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 z11si11258309plo.211.2017.12.19.10.04.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Dec 2017 10:04:17 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-88355-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=qk/CpqCb; spf=pass (google.com: domain of libc-alpha-return-88355-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-88355-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:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=Nr7 R5jUaoHQgdQjaxDOuhnHbR7mw4pLV3AodFOt9WDgs+MR1cadEfBoRApCAZ9Xlvog +TIovRelMWzVOankNDPtLvi46YAKqiV3NTOJ0i/gDY0CrAOOJgjkJ8QBoxW6x+24 Q22Dxx09I98RuBkgE3A1LTPV0F+zw9GLo7cR+JcI= 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:mime-version :content-type:content-transfer-encoding; s=default; bh=Eg1bXPGgZ w/q/nt8tT55rlVKRzQ=; b=qk/CpqCb1njY2DLARMJi8MkY3wG3eVfBg22LrJPp4 FzHdts23czZ/6iMQ5VtO2oHOvh8buDGLD2VMJMjNwZF7D3IGd1zT0I8sg97t4IS9 7/o02LJ5FFnhECYUyNFTmy3CIKaYfK3pVsWdj25dMHjYodg0mxv3S2tvVZ/97XWq s0= Received: (qmail 96124 invoked by alias); 19 Dec 2017 18:04:08 -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 96114 invoked by uid 89); 19 Dec 2017 18:04:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=HContent-Transfer-Encoding:8bit X-HELO: mail-qk0-f193.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:mime-version :content-transfer-encoding; bh=Vb0UjslSNKcGbLhzoQadW9AIB6q2Bm9ad+YLJ6MVqzA=; b=fgAnnsSPcqgoJxOOht6y/Ibls+Cu3WxeANjsC6/AbvhH63VdMgdu5sYOoGu2nWgSKg CV0RJj3j4SBRMkKv4wnJUmVqCgWE8mgivfLcGLa1Bm6VoH+c+Na/Wt0WPh5UVI5R+QrK KbuXY65S/AyZsQocxsjYxvChxfFn/UBy5zBRTmqdTIVYGrRVT7s7bJYIIx8EECrWQTaH VNcM1Fn63e0sDb31osdhq+H7PjQeFIGFkpDos0Ton9wLhHV0KfWLM84dZHKn9TFZvSbO GGLymKgnvELOWmtsxufZPE9qXdV8/GrIv4hIZvJtxudS0JJ94bHvJ7d+DxGQDQJHu13i bCEg== X-Gm-Message-State: AKGB3mLzEstevsuEcwT+Buj04yykSL4IReR8sQLhVsSIHByXsuyxamYm WviK8VcdcuAPqjc56JFwIl2ZXhf4/Ow= X-Received: by 10.55.145.197 with SMTP id t188mr6055893qkd.267.1513706644162; Tue, 19 Dec 2017 10:04:04 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [COMMITTED] glob: pacify fuzzer for mempcpy Date: Tue, 19 Dec 2017 16:03:58 -0200 Message-Id: <1513706639-12259-1-git-send-email-adhemerval.zanella@linaro.org> MIME-Version: 1.0 Problem reported by Tim Rühsen [1]. Sync with gnulib 0e14f025d2. [1] https://lists.gnu.org/archive/html/bug-gnulib/2017-10/msg00054.html Checked on x86_64-linux-gnu. * lib/glob.c (glob): Do not pass NULL to mempcpy. Signed-off-by: Adhemerval Zanella --- ChangeLog | 4 ++++ posix/glob.c | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/posix/glob.c b/posix/glob.c index cb39779..511ec4b 100644 --- a/posix/glob.c +++ b/posix/glob.c @@ -826,6 +826,7 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), { size_t home_len = strlen (p->pw_dir); size_t rest_len = end_name == NULL ? 0 : strlen (end_name); + char *d; if (__glibc_unlikely (malloc_dirname)) free (dirname); @@ -845,8 +846,10 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), } malloc_dirname = 1; } - *((char *) mempcpy (mempcpy (dirname, p->pw_dir, home_len), - end_name, rest_len)) = '\0'; + d = mempcpy (dirname, p->pw_dir, home_len); + if (end_name != NULL) + d = mempcpy (d, end_name, rest_len); + *d = '\0'; dirlen = home_len + rest_len; dirname_modified = 1;