Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3333418pxj; Mon, 24 May 2021 04:26:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWZB+1A0E5dWgcx/Ko4dE7PdLQh7OuYbSDG5n2L659L/RE9K5cBfQO0rNuS+6j11fLUixs X-Received: by 2002:aa7:d7d5:: with SMTP id e21mr25466352eds.78.1621855593107; Mon, 24 May 2021 04:26:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621855593; cv=none; d=google.com; s=arc-20160816; b=JcznwaqkC3/07xFmKL/gBOgLWlxBdX0S7Jp0BMwMXmYwkf3DJM8BXMPTnOkDii32h3 VtsNUSqrRjvevBBs4JcGe1kHPWg0V7z2UYOu6PSfltn1fTLwp+cAhhGUbrAqTvEW23eA PqScJ2FKMMYlr5bTPHTyTgOe+5Tgju6pGBz+3mFQ5mwnKxiY3a59H5CKb5fOg1OV55OL cpjgyZGRlJx5eZtcHBnsS1EIjZrzrYYCCaxshmQETn/zgv1FpTpcwpZbdqBaDY1kNqoR 3QU562d+j0sqSPRyKe1Nht8Nprw5I9xDUitW5qhqsFX8NmGmWxvqGqGVdODb9VaPl/1r 5KyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:references:cc:to:from :subject; bh=q95r3+Th1jkjvX1Dy8JnyLPeTsAUz+y+JryzQ+50tPI=; b=BZbI2ugikSTZ2mRxKdqaiOABvHqKKi4FdEwZmg/PIso1w5vt7PrPFlg4NJ9v66pf3V bFPYrASZSoXCbFwqJ1F/S+6JFRHens6t/I5pjiqORU262j370tQiE8topRmC2NQEJg8v +P+LB4WOoagSufVxWMYTb65AAfrSfVNEhkNyRMKvOD5/eZGl/2Jb34JQxvGOY/ksoxTE pkgf0Pvwf+Za6zEyBOYo7TRwZnxbPgFYtpYPQsL2/R3q/7z27HSEZedv7JO0f2ppCGNX x6nRH+wsLNTQ8vAiFZXXXLSYUHUW47knt+dZRBjOChV5VUwypCTDxcxe8Qivj/rcB1/m Wm+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cy11si10012623edb.253.2021.05.24.04.26.10; Mon, 24 May 2021 04:26:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232516AbhEXL10 (ORCPT + 99 others); Mon, 24 May 2021 07:27:26 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5754 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232547AbhEXL1Z (ORCPT ); Mon, 24 May 2021 07:27:25 -0400 Received: from dggems705-chm.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FpZYp0QCszmkp3 for ; Mon, 24 May 2021 19:22:22 +0800 (CST) Received: from dggpemm500014.china.huawei.com (7.185.36.153) by dggems705-chm.china.huawei.com (10.3.19.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 24 May 2021 19:25:56 +0800 Received: from [10.174.179.184] (10.174.179.184) by dggpemm500014.china.huawei.com (7.185.36.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 24 May 2021 19:25:56 +0800 Subject: [PATCH 11/12] misc/lsattr: check whether path is NULL in, lsattr_dir_proc() From: Wu Guanghao To: CC: , References: <266bc52e-e279-ce84-0e1f-1405b9bc6174@huawei.com> Message-ID: <33b89334-78cc-a7a3-941f-9576fbd24291@huawei.com> Date: Mon, 24 May 2021 19:25:56 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.2.1 MIME-Version: 1.0 In-Reply-To: <266bc52e-e279-ce84-0e1f-1405b9bc6174@huawei.com> Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.184] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500014.china.huawei.com (7.185.36.153) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org In lsattr_dir_proc(), if malloc() return NULL, it will cause a segmentation fault problem. Signed-off-by: Zhiqiang Liu Signed-off-by: Wu Guanghao --- misc/lsattr.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/misc/lsattr.c b/misc/lsattr.c index 0d954376..f3212069 100644 --- a/misc/lsattr.c +++ b/misc/lsattr.c @@ -144,6 +144,12 @@ static int lsattr_dir_proc (const char * dir_name, struct dirent * de, int dir_len = strlen(dir_name); path = malloc(dir_len + strlen (de->d_name) + 2); + if (!path) { + fprintf(stderr, "%s", + _("Couldn't allocate path variable " + "in lsattr_dir_proc")); + return -1; + } if (dir_len && dir_name[dir_len-1] == '/') sprintf (path, "%s%s", dir_name, de->d_name); --