From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from g9t5008.houston.hpe.com (g9t5008.houston.hpe.com [15.241.48.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id F0E4C81C01 for ; Wed, 11 Jan 2017 19:39:43 -0800 (PST) Received: from HEGDENAG9.asiapacific.hpqcorp.net (hegdenag9.asiapacific.hpqcorp.net [16.154.153.125]) by g9t5008.houston.hpe.com (Postfix) with ESMTP id F1FBA56; Thu, 12 Jan 2017 03:39:40 +0000 (UTC) From: hegdenag To: edk2-devel@lists.01.org Cc: jiaxin.wu@intel.com, jaben.carsey@intel.com, ruiyu.ni@intel.com, lubo.zhang@intel.com, sriram-s@hpe.com Date: Thu, 12 Jan 2017 09:09:38 +0530 Message-Id: <20170112033938.14220-1-nagaraj-p.hegde@hpe.com> X-Mailer: git-send-email 2.8.3.windows.1 Subject: [PATCH v1 1/1] ShellPkg/Ifconfig6: Address ASSERT because of a missing NULL check X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jan 2017 03:39:44 -0000 When we issue 'ifconfig6 -s auto' system hangs with an ASSERT in StrLen. in IfConfig6SetInterfaceInfo, for 'auto' case we added checks to rule out the invalid inputs like 'host', 'gw' and 'dns'. To parse through this, we do a VarArg = VarArg->Next but we dont check new VarArg before calling StrCmp. Fix with a check in this patch. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hegde Nagaraj P --- ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c | 27 ++++++++++---------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c index d71688e..72aaee4 100644 --- a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c +++ b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c @@ -1317,20 +1317,21 @@ IfConfig6SetInterfaceInfo ( VarArg= VarArg->Next; - if (StrCmp (VarArg->Arg, L"host") == 0) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_IP_CONFIG), gShellNetwork2HiiHandle, Status); - ShellStatus = SHELL_INVALID_PARAMETER; - goto ON_EXIT; - } else if (StrCmp (VarArg->Arg, L"gw") == 0) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_GW_CONFIG), gShellNetwork2HiiHandle, Status); - ShellStatus = SHELL_INVALID_PARAMETER; - goto ON_EXIT; - } else if (StrCmp (VarArg->Arg, L"dns") == 0) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_DNS_CONFIG), gShellNetwork2HiiHandle, Status); - ShellStatus = SHELL_INVALID_PARAMETER; - goto ON_EXIT; + if (VarArg != NULL) { + if (StrCmp (VarArg->Arg, L"host") == 0) { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_IP_CONFIG), gShellNetwork2HiiHandle, Status); + ShellStatus = SHELL_INVALID_PARAMETER; + goto ON_EXIT; + } else if (StrCmp (VarArg->Arg, L"gw") == 0) { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_GW_CONFIG), gShellNetwork2HiiHandle, Status); + ShellStatus = SHELL_INVALID_PARAMETER; + goto ON_EXIT; + } else if (StrCmp (VarArg->Arg, L"dns") == 0) { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_ERR_INVALID_DNS_CONFIG), gShellNetwork2HiiHandle, Status); + ShellStatus = SHELL_INVALID_PARAMETER; + goto ON_EXIT; + } } - } else if (StrCmp (VarArg->Arg, L"man") == 0) { // // Set manual config policy. -- 2.8.3.windows.1