Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68332C433F5 for ; Fri, 31 Dec 2021 07:42:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242743AbhLaHmE (ORCPT ); Fri, 31 Dec 2021 02:42:04 -0500 Received: from szxga01-in.huawei.com ([45.249.212.187]:34865 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229636AbhLaHmD (ORCPT ); Fri, 31 Dec 2021 02:42:03 -0500 Received: from dggpeml500023.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4JQHC02JfZzcc6n; Fri, 31 Dec 2021 15:41:32 +0800 (CST) Received: from dggpeml100016.china.huawei.com (7.185.36.216) by dggpeml500023.china.huawei.com (7.185.36.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Fri, 31 Dec 2021 15:42:02 +0800 Received: from [10.174.176.102] (10.174.176.102) by dggpeml100016.china.huawei.com (7.185.36.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Fri, 31 Dec 2021 15:42:01 +0800 Message-ID: <9cb10a07-383c-cc45-d917-7f5a74b31d39@huawei.com> Date: Fri, 31 Dec 2021 15:42:01 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: [PATCH v2 2/6] lib/ss: check whether argp is null before accessing it, in ss_execute_command() From: zhanchengbin To: Theodore Ts'o CC: , , , References: <52a2a39d-617f-2f27-a8a4-34da6103e44c@huawei.com> In-Reply-To: <52a2a39d-617f-2f27-a8a4-34da6103e44c@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.176.102] X-ClientProxiedBy: dggpeml100004.china.huawei.com (7.185.36.247) To dggpeml100016.china.huawei.com (7.185.36.216) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org In ss_execute_command(), we should check whether argp is null before accessing it, otherwise the null potinter dereference error may occur. Signed-off-by: zhanchengbin --- lib/ss/execute_cmd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ss/execute_cmd.c b/lib/ss/execute_cmd.c index d443a468..b6e4a5dc 100644 --- a/lib/ss/execute_cmd.c +++ b/lib/ss/execute_cmd.c @@ -171,6 +171,8 @@ int ss_execute_command(int sci_idx, register char *argv[]) for (argp = argv; *argp; argp++) argc++; argp = (char **)malloc((argc+1)*sizeof(char *)); + if (argp == NULL) + return (SS_ET_COMMAND_NOT_FOUND); for (i = 0; i <= argc; i++) argp[i] = argv[i]; i = really_execute_command(sci_idx, argc, &argp); -- 2.27.0