Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3332819pxj; Mon, 24 May 2021 04:25:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMR6OKXVV2cZNCLQbFceuCjoJZ7k81aR0ayoJ7E7vRW3Ih3AGjXVGM0hBJOdvP1TxVwAq/ X-Received: by 2002:a17:906:68e:: with SMTP id u14mr22056313ejb.434.1621855533800; Mon, 24 May 2021 04:25:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621855533; cv=none; d=google.com; s=arc-20160816; b=JUYMzz+gC34IxEiQzVqVb9wpggdje/hOP6A7AWwWsnbJ2dt+Bf7ib/5xoWZqYutI/T 17M9lyF36ygCuSqUEJdEgigu7KyHFqTxseqR4QyVQDcNZ3NXU5xZ62uCgWCJqgUfFUli 94ul2VqMCpApbXQBpi17POEmlVvEZ9+bR/VyGLCjTusd2TiY9NiJsQOMGKr+Q7L/m8kh /BNaqmgNe0YP4abhiGbayaBjeuYsLWcET0HhHzUeV/ZV8aXdu/kmDYuLbR9BHGI+VnVV FQSkJ+P9VofWBrsA/4Md/LG4ewvMZewA8eyFgiePGSrU4gYB38fpJf8Liul8B+vCWklN eDzw== 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=0zUPMnmNYXVeY9W/QAEmiYyLHEPsu+4lLRDMlU6Mjuw=; b=uvQaxCgf8qHcMN05c9n4KBYzT+3SCQUhQqTYt9iC75xkuU1pdooysfqbsJeM/UoBK/ htBNNddIYzYtTjAxqFsuW5XUjz1hpj6w8DQ8rHcKktrr8nKnn4yrOIDUvkh55Gk2q+yI 0Btha0huwLW8m6etEhVuDv4ern3zqEymo6tNswSHyMsSQXMXEomhr0Gk3ulok0tbeMc1 1fC87CX7wDN0VuTwIPkUE8w7aOBqvtmx7ANILbGdgOVqu0+beDoI0cK8HL1E+2mSy61o RD7G00C2ZQ8F4QIMbHXhmRLTc+E8tQhFrWtVPFyNqYgeEEiAIbhVLrZLFZiIcX3vJ54/ Vl9A== 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 mp30si11884304ejc.262.2021.05.24.04.25.10; Mon, 24 May 2021 04:25: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 S232854AbhEXLZt (ORCPT + 99 others); Mon, 24 May 2021 07:25:49 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:3925 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232859AbhEXLZ1 (ORCPT ); Mon, 24 May 2021 07:25:27 -0400 Received: from dggems704-chm.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4FpZXM1MZhzCx5q for ; Mon, 24 May 2021 19:21:07 +0800 (CST) Received: from dggpemm500014.china.huawei.com (7.185.36.153) by dggems704-chm.china.huawei.com (10.3.19.181) 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:23:57 +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:23:57 +0800 Subject: [PATCH 07/12] argv_parse: check return value of malloc in argv_parse() From: Wu Guanghao To: CC: , References: <266bc52e-e279-ce84-0e1f-1405b9bc6174@huawei.com> Message-ID: <5d711bbc-50bb-c8a5-a118-e22a691c0d7f@huawei.com> Date: Mon, 24 May 2021 19:23:57 +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: dggems705-chm.china.huawei.com (10.3.19.182) 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 (!arcv) + return -1; } argv[argc] = 0; if (ret_argc) --