public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ruiyu" <ruiyu.ni@Intel.com>
To: Jim.Dailey@dell.com
Cc: michael.d.kinney@intel.com, liming.gao@intel.com,
	edk2-devel@lists.01.org
Subject: Re: [PATCH] MdePkg-BaseLib: Fix PathCleanUpDirectories() error involving "\..\.."
Date: Tue, 9 Oct 2018 10:55:25 +0800	[thread overview]
Message-ID: <060d11fe-ffce-0d7f-00af-bd3353ce990e@Intel.com> (raw)
In-Reply-To: <c8ccaad1befc4db4bcd3f835930c2508@ausx13mps335.AMER.DELL.COM>

On 10/8/2018 9:23 PM, Jim.Dailey@dell.com wrote:
>> -----Original Message-----
>>>
>>> diff --git a/MdePkg/Library/BaseLib/FilePaths.c b/MdePkg/Library/BaseLib/FilePaths.c
>>> index d6f3758ecb..5d3de01894 100644
>>> --- a/MdePkg/Library/BaseLib/FilePaths.c
>>> +++ b/MdePkg/Library/BaseLib/FilePaths.c
>>> @@ -2,6 +2,7 @@
>>>      Defines file-path manipulation functions.
>>>    
>>>      Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
>>> +  Copyright (c) 2018, Dell Technologies. All rights reserved.<BR>
>>>      This program and the accompanying materials
>>>      are licensed and made available under the terms and conditions of the BSD License
>>>      which accompanies this distribution.  The full text of the license may be found at
>>> @@ -103,7 +104,9 @@ PathCleanUpDirectories(
>>>            ) {
>>>        *(TempString + 1) = CHAR_NULL;
>>>        PathRemoveLastItem(Path);
>>> -    CopyMem (Path + StrLen (Path), TempString + 3, StrSize (TempString + 3));
>>> +    if (*(TempString + 3)) {
>>> +      CopyMem (Path + StrLen (Path), TempString + 4, StrSize (TempString + 4));
>>> +    }
I just setup a debugging environment to trace the code. Finally I 
understand the issue.
I agree to change "TempString + 3" to "TempString + 4". This can 
eliminate double slash so in next same loop, the pattern "\\..\\" or 
"\\..\0" can be detected and "last item" can be correctly removed by 
PathRemoveLastItem().

Can you change
  "if (*(TempString + 3))"
  to
  "if (*(TempString + 3) != CHAR_NULL)"?

With the above change, Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
If you agree, I can modify your patch and push it for you.

>>>      }
>>>    
>>>      //
>>>
>> Jim,
>> Are you fixing a corner case bug introduced by following commit:
>>
>>> SHA-1: bb99e3282c9e69fbd6365d117c58d15589e34c5d
>> * MdePkg/BaseLib: Fix PathCleanUpDirectories to correctly handle "\.\"
>>
>>> The old code incorrectly cleans path like "fs0:\abc\.\.." to
>>> "fs0:\abc", instead of "fs0:\"
>>
>>> The patch fixes this bug.
> 
> Honestly, because of the scope of bb99e328, I cannot say for sure, but
> my inclination is to answer "No."
> 
> The current fix is strictly related to handling paths that include two
> or more references to the previous directory, whether or not one of them
> abuts a reference to the current directory (as in the bb99e328 fix).
> 
> Regards,
> Jim
> 


-- 
Thanks,
Ray


  reply	other threads:[~2018-10-09  2:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-04 15:03 [PATCH] MdePkg-BaseLib: Fix PathCleanUpDirectories() error involving "\..\.." Jim.Dailey
2018-10-08  7:00 ` Ni, Ruiyu
2018-10-08 13:23   ` Jim.Dailey
2018-10-09  2:55     ` Ni, Ruiyu [this message]
2018-10-09 11:40       ` Jim.Dailey
2018-10-08 15:26   ` Jim.Dailey
2018-10-08 15:46     ` Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=060d11fe-ffce-0d7f-00af-bd3353ce990e@Intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox