Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3333928pxj; Mon, 24 May 2021 04:27:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxILGyv6GXMSOMLPd3ah/h4auFq1ATnRP0Q2tutk0Q9AiNvANoF0Z1PPgaehz1XCxeaKAwX X-Received: by 2002:a05:6e02:4ac:: with SMTP id e12mr15096394ils.21.1621855639682; Mon, 24 May 2021 04:27:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621855639; cv=none; d=google.com; s=arc-20160816; b=0+kGK6OECrC/HSmrAc5Nr/y73LAyfP5mSw8R2WVe0x3+gYN6udHf8W+XkD/XpplN69 QwQnHam1kHbCoOQY2WLIcUQUpQxl5JEJqevQ0dPYNlH7RkgoCYLEosue7QRrZtl4Ms+m 3Mec64xpY6YKsuQQQR5gfaTvw3czyL/3hG9NvWLwbivh5cJoONIlCgkq7F48/GxI+1FQ w3HhPvjezmGuRarjaGYvBogWQEuPgTagH6cXskkq5/HGHJB5PkR4VvTt0ypGTo6gZsZK ntsw25UtPBE4Nhj/gRIDwQdf0ywP1D3wlcO78EdS1jBy4eLhR1ANltO59xPQ0PKmpxdd RkQg== 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=u9YAZZlvlALQltTrab9zqhva9QYBN98wGaIfC+tuGZ4=; b=oOS5o1DSnwajhKFuJClQU+PpkAzSuCrua8ebR53hZaW12anHq7Owb3f1PvVfwumR36 RxYiN/rTMouqnjtQJuryMPAOogJ+VihfyBRUWpo1R3ePWMQLAiix9ghyZsylI4rKFnZr OaxQMWX5ysudUeasuXLeF7n9QvPcOMIJdTtCQRWZW7iGAP0qY63jXVB6D8p2Q+yFIpY3 HMIMFVwY/zbD+tBb2ymMmzGMFf10spsIRj+od7QLSThl7yPzuMhywhzmatDopfDao48u Le72ikAZjECbitomrMJWXDY5MokmU3hFRdoC//O4As6L8EB4L45vAqzdImcZm8LG+Ave WsXg== 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 h19si14254963jaj.3.2021.05.24.04.27.07; Mon, 24 May 2021 04:27:19 -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 S232070AbhEXL2H (ORCPT + 99 others); Mon, 24 May 2021 07:28:07 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:3644 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232050AbhEXL2G (ORCPT ); Mon, 24 May 2021 07:28:06 -0400 Received: from dggems706-chm.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FpZZY5MfyzNyyF for ; Mon, 24 May 2021 19:23:01 +0800 (CST) Received: from dggpemm500014.china.huawei.com (7.185.36.153) by dggems706-chm.china.huawei.com (10.3.19.183) 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:26:37 +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:26:36 +0800 Subject: [PATCH 12/12] ext2ed: fix potential NULL pointer dereference in, dupstr() From: Wu Guanghao To: CC: , References: <266bc52e-e279-ce84-0e1f-1405b9bc6174@huawei.com> Message-ID: Date: Mon, 24 May 2021 19:26:36 +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: dggems701-chm.china.huawei.com (10.3.19.178) 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 dupstr(), we should check return value of malloc(). Signed-off-by: Zhiqiang Liu Signed-off-by: Wu Guanghao Reviewed-by: Wu Bo --- ext2ed/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext2ed/main.c b/ext2ed/main.c index f7e7d7df..9d33a8e1 100644 --- a/ext2ed/main.c +++ b/ext2ed/main.c @@ -524,6 +524,8 @@ char *dupstr (char *src) char *ptr; ptr=(char *) malloc (strlen (src)+1); + if (!ptr) + return NULL; strcpy (ptr,src); return (ptr); } --