Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp126629pxv; Wed, 30 Jun 2021 01:28:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTW5JHCFeOly3DWxG61zXbvqIGg+Rrx4BHEL9KqNfZ7tKjL74+clqX9FqGXkC0b/rAKiTr X-Received: by 2002:a02:76d2:: with SMTP id z201mr7931364jab.21.1625041693574; Wed, 30 Jun 2021 01:28:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625041693; cv=none; d=google.com; s=arc-20160816; b=iID9cSdyWXgTZso+ptKM2Q7+FureP28f+wH6Ng89lzzHZNWTu4fmrDiWxuF6PHnfB2 BXHfmOMuc4f22ue8RUxydUfXvwQvWabXfmsZTpaatEKs3dxtoj1ZfwjqsAQEjsrLKBrb HCtBmVbAJMGYNtueJ/Jj98QfHT0wiDfVsOrhwSLG8MNazcOvMkyPrQoZkZwEn/ySvzbN qNqd1PiofxsFcEbP68T8KfOry18gLMZEC5wG0cVGV3AXapPTNI2Lv3KagN6qzXgr3TeY NFIFQJla5Wzem5li8BaMgO8kWFgsaAAnA9Bc18XPleXhoSxHDhHgG0cjdEgSaiTmyDEI 9CyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=9tZ4kU76fTVmDBOd4aFMMj8QWfRJZPxg0Z40XS64VUY=; b=wFFfuqqI8okiIbsdwKPd1qy3ZMeN4Izg6nMT5f9lisjGLMnjZHcNcJpsQ2BYWOdFXw xybWcjOuD/aII7EI8PY6NeByvTYquuFD+3Fe4aRTvD26HIAwP0d6YKPPv4n4qtYMyC0O rU0Cp8cncwmersEurmYrGOD6O9m+AWvnZZCSFQQrH8cQ1crUVu/aA33WaiI/NaZgYn1e Y/sDGZicy3UfH2Vy8fClADdVk6A1C6z/z6cOjYNiArTLgNjHHLuxjnq96a3NuYDTY4yK ixVgQ5wXVuLvxQeG1Uk7Hx5Uyf/oCPCRzePhm2TdlpQid/Kv1ZWIJsdxEfJU3ouJ0ZQm K3Pg== 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 j20si25451077jak.8.2021.06.30.01.28.01; Wed, 30 Jun 2021 01:28:13 -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 S233543AbhF3IaR (ORCPT + 99 others); Wed, 30 Jun 2021 04:30:17 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:9328 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233552AbhF3IaO (ORCPT ); Wed, 30 Jun 2021 04:30:14 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4GFDrL5pqYz74JP for ; Wed, 30 Jun 2021 16:23:30 +0800 (CST) Received: from dggpemm500014.china.huawei.com (7.185.36.153) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 30 Jun 2021 16:27:33 +0800 Received: from huawei.com (10.175.104.170) 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; Wed, 30 Jun 2021 16:27:33 +0800 From: wuguanghao To: , CC: , , Subject: [PATCH v2 07/12] argv_parse: check return value of malloc in argv_parse() Date: Wed, 30 Jun 2021 16:27:19 +0800 Message-ID: <20210630082724.50838-8-wuguanghao3@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210630082724.50838-2-wuguanghao3@huawei.com> References: <20210630082724.50838-2-wuguanghao3@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.170] 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 From: Zhiqiang Liu In argv_parse(), return value of malloc should be checked whether it is NULL, otherwise, it may cause a segfault error. Signed-off-by: Zhiqiang Liu Signed-off-by: Wu Guanghao --- lib/support/argv_parse.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/support/argv_parse.c b/lib/support/argv_parse.c index d22f6344..1f50f9e5 100644 --- a/lib/support/argv_parse.c +++ b/lib/support/argv_parse.c @@ -116,6 +116,8 @@ int argv_parse(char *in_buf, int *ret_argc, char ***ret_argv) if (argv == 0) { argv = malloc(sizeof(char *)); free(buf); + if (!argv) + return -1; } argv[argc] = 0; if (ret_argc) -- 2.19.1