Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2224186pxj; Sun, 30 May 2021 18:32:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/ir1Uxw0uyojTliXi+yvO8J7a3rxtKdsiiw8JmjE1tB7fTCcXkJhEsyt0oFOGq6bJzcpm X-Received: by 2002:a02:cf32:: with SMTP id s18mr18074839jar.31.1622424723454; Sun, 30 May 2021 18:32:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622424723; cv=none; d=google.com; s=arc-20160816; b=zDPDf4HW+XTYe88JuJLdp0rj6lp5AfzqdEWh3h2Osi+7l8/YfEdBJlrnOFVZPlT7ED Jtl82f5gZqFKAFaVlIh7O6KZgQwpza5bvnSiMG07qN6SwDxkMmFqmBXfcBAseH/9IBmz rWMTDMTWhvc9nHSM1g65Oo7LxWWmQvrypwKsBLkpLCcZCiMn/ox0m0JjSyFujhf2c1Q4 HMjRwRNByqBnOF3n2hT6jPRBqY/N5t7xelO8XoMjjb6SFahuUO+cKZ5Q94XGmqX/3vnj QOupW2GRq9paPSoJMAuR29WKDnSbFs9c7/q5K+XeFpQRlMuKKaUcDfcndxgRI39PsNt9 s0pA== 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=V07DKtWe0MgphI7gvE8e8vK6MumHIHhvQUsHSqKBnOE=; b=tZJPExSHQpokR0QCeNN7d2hg34RNRWY5KJOfrCueu8/b/lHDcOMeausLqMk0eIy7L6 xTeFaS3G4sLNWgMo1aLpj7l579Wxv8KQFwrvFGjY4i5qdZ6d6k1IpQ1g6ChX/rhcWyW6 NfYOawfXD7KIoXvf+j00lfEHy7Sko1XIRt6B5u+UPi0ExzroZT56FYzT2Greh8N+FTnL CqMispdHmFJb7oWMdkOAx1bIerWXZnYOmVPAv/9kImTtkYiZO6Uj5ufJxhA5CZHL2nCg 9V1fukYrmN6AJt22zd4wrRIHqdJyXEmFhyGAmWhnAeS8iHWX8KXVWsTF0V76xm45Y602 IT5Q== 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 n4si11891864ion.59.2021.05.30.18.31.50; Sun, 30 May 2021 18:32:03 -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 S229941AbhEaBdM (ORCPT + 99 others); Sun, 30 May 2021 21:33:12 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:6080 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229891AbhEaBdL (ORCPT ); Sun, 30 May 2021 21:33:11 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Ftd3h5DkzzYmyV for ; Mon, 31 May 2021 09:28:48 +0800 (CST) Received: from dggpemm500014.china.huawei.com (7.185.36.153) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 31 May 2021 09:31:31 +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, 31 May 2021 09:31:30 +0800 Subject: [PATCH V2 07/12] argv_parse: check return value of malloc in argv_parse() From: Wu Guanghao To: , =?UTF-8?B?0JHQu9Cw0LPQvtC00LDRgNC10L3QutC+INCQ0YDRgtGR0Lw=?= CC: , References: <00ad4a90-8a40-24c1-98d9-eb5f0da42436@huawei.com> Message-ID: <40063d0f-09dd-c7e6-fbd4-19b4438284ee@huawei.com> Date: Mon, 31 May 2021 09:31:30 +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: <00ad4a90-8a40-24c1-98d9-eb5f0da42436@huawei.com> Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.184] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) 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 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..1ef9c014 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) --