bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#10472: [PATCH] realpath: fix problems with // handling


From: Eric Blake
Subject: bug#10472: [PATCH] realpath: fix problems with // handling
Date: Tue, 13 Mar 2012 21:15:16 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1

On 02/20/2012 08:21 AM, Pádraig Brady wrote:
> On 02/04/2012 07:05 PM, Eric Blake wrote:
>> On platforms like Cygwin where / and // are distinct, realpath was
>> incorrectly collapsing // into /.  http://debbugs.gnu.org/10472.
>>

>> This is the coreutils side of the patch; for this to work, we also
>> have to upgrade to the latest gnulib.

The gnulib update has happened in the meantime.

>>
>> I'm not pushing this until we decide what to do about testing; I
>> guess we've already figured out how to make basename and dirname
>> tests conditional on whether they are on Linux or Cygwin (that is,
>> whether // and / are the same or different), so I should do something
>> similar to that for the realpath test.  But I can at least get a
>> code review on realpath.c while figuring out the testing situation.

I'm planning on resubmitting this series soon, once I polish my test,
with hopes of inclusion in this week's release.

>> +++ b/src/realpath.c
>> @@ -131,6 +131,10 @@ path_common_prefix (const char *path1, const char 
>> *path2)
>>    int i = 0;
>>    int ret = 0;
>>
>> +  if (DOUBLE_SLASH_IS_DISTINCT_ROOT && *path1 == '/' && *path2 == '/'
>> +      && (path1[1] == '/') != (path2[1] == '/'))
>> +    return 0;
>> +
>>    while (*path1 && *path2)
>>      {
>>        if (*path1 != *path2)

> is the DOUBLE_SLASH_IS_DISTINCT_ROOT check needed in realpath.c
> I.E. if we get a leading // then that define is implicit?

Good point - path_common_prefix is only ever called with canonical
names, which means that it will only ever encounter // on systems where
it matters.

> 
> Also doesn't path_prefix() need the same adjustment,
> so as to verify --relative-base in the same way?

Yes, it looks like it.

-- 
Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]