From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.85.221.68; helo=mail-wr1-f68.google.com; envelope-from=philmd@redhat.com; receiver=edk2-devel@lists.01.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 271C12118D94A for ; Wed, 7 Nov 2018 09:09:17 -0800 (PST) Received: by mail-wr1-f68.google.com with SMTP id d10-v6so18226181wrs.5 for ; Wed, 07 Nov 2018 09:09:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ccAM+TX8/LDAUeUiE/fJ72hKaxumEEnqmF85GvcthG8=; b=T7iTd1QrbpaMGRSVGKd4q+jmDXhAV3QMh7C4hG3fAnB8pWAw9867VYJEB70z3rRyZf vnzKqJ9P5xh7q8sqat484mnFMGwR/NCJWBQYdJSjc/BxlM9xFueNhaFx3UkeiMdQ4rkP 6uEm93zJwr5LfIvjUP7BcYy1E5EsEYP2epkSrNXnQ8U2XLKRtbGjco/sySnEYOWWoT1Q vXIJklsDGiOOU5SqsOx0wQIGqeULnygrMn417dwAcEjxR7pohoil3cnqI5u1FGxAZu5W Piuq/K7mM30VGiLm3QORxWIIGjla0hY4F4Kj3FNrwKsOw93+JeN0mYf/NedupM6jGpRF CiKg== X-Gm-Message-State: AGRZ1gIsHDd2KHujes315UDfCH8qvvO1QRs2+oQiiYP4zvP3U1gk0V8+ vnjBdwT5OJWOW2wCo360/2wYFA== X-Google-Smtp-Source: AJdET5ey0HgEun1Zu/Hg/bL8B9qV8P4g1KO8TkABZHXdAdmg6sEPvGsjQPyAnRqMxEBNM11OCiquOQ== X-Received: by 2002:a5d:47d2:: with SMTP id l18-v6mr1044620wrs.319.1541610555592; Wed, 07 Nov 2018 09:09:15 -0800 (PST) Received: from [10.0.0.124] ([185.102.219.36]) by smtp.gmail.com with ESMTPSA id p125-v6sm4055212wmp.2.2018.11.07.09.09.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 09:09:15 -0800 (PST) To: Ruiyu Ni , edk2-devel@lists.01.org Cc: Hao A Wu , Jim Dailey References: <20181107093637.168244-1-ruiyu.ni@intel.com> From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= Message-ID: <75e687bd-575e-ba2d-0378-d3c9c554db68@redhat.com> Date: Wed, 7 Nov 2018 18:09:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181107093637.168244-1-ruiyu.ni@intel.com> Subject: Re: [PATCH] ShellPkg/ShellLib: Fix potential NULL deference issue X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Nov 2018 17:09:17 -0000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit On 7/11/18 10:36, Ruiyu Ni wrote: > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ruiyu Ni > Cc: Jim Dailey > Cc: Hao A Wu Reviewed-by: Philippe Mathieu-Daudé > --- > ShellPkg/Library/UefiShellLib/UefiShellLib.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c > index 580a1ee612..b17266d623 100644 > --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c > +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c > @@ -72,6 +72,7 @@ FullyQualifyPath( > { > CONST CHAR16 *WorkingPath; > CONST CHAR16 *InputPath; > + CHAR16 *CharPtr; > CHAR16 *InputFileSystem; > UINTN FileSystemCharCount; > CHAR16 *FullyQualifiedPath; > @@ -131,7 +132,10 @@ FullyQualifyPath( > // truncate the new path after the file system part. > // > StrCpyS(FullyQualifiedPath, Size/sizeof(CHAR16), WorkingPath); > - *(StrStr(FullyQualifiedPath, L":") + 1) = CHAR_NULL; > + CharPtr = StrStr(FullyQualifiedPath, L":"); > + if (CharPtr != NULL) { > + *(CharPtr + 1) = CHAR_NULL; > + } > } else { > // > // Relative path: start with the working directory and append "\". >