Skip Menu |
 

This queue is for tickets about the PathTools CPAN distribution.

Report information
The Basics
Id: 98370
Status: new
Priority: 0/
Queue: PathTools

People
Owner: Nobody in particular
Requestors: Greg.Aloe [...] mathworks.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



CC: "dmuey [...] cpan.org" <dmuey [...] cpan.org>
MIME-Version: 1.0
X-Spam-Status: No, score=-4.867 tagged_above=-99.9 required=10 tests=[BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_MED=-2.3, RP_MATCHES_RCVD=-0.668] autolearn=ham
X-Spam-Flag: NO
X-Virus-Checked: Checked
Content-Language: en-US
Content-Type: multipart/alternative; boundary="_000_adaadee012084b6da12d3930c3b8e1b6ex13amer01ahadmathworks_"
Message-ID: <adaadee012084b6da12d3930c3b8e1b6 [...] ex13amer-01-ah.ad.mathworks.com>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-MS-Tnef-Correlator:
X-Spam-Score: -4.867
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 4C8D72401BE for <cpan-bug+PathTools [...] hipster.bestpractical.com>; Wed, 27 Aug 2014 18:01:10 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id z1qrc3jwFLjR for <cpan-bug+PathTools [...] hipster.bestpractical.com>; Wed, 27 Aug 2014 18:01:07 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 288A5240021 for <bug-PathTools [...] rt.cpan.org>; Wed, 27 Aug 2014 18:01:06 -0400 (EDT)
Received: (qmail 32113 invoked by alias); 27 Aug 2014 22:01:06 -0000
Received: from mail-out-ah.mathworks.com (HELO mail-out-ah.mathworks.com) (144.212.100.28) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Wed, 27 Aug 2014 15:01:02 -0700
Received: from mail-vif.mathworks.com (newscl02ah.mathworks.com [144.212.95.122]) by mail-out-ah.mathworks.com (8.14.4/8.14.4) with ESMTP id s7RM0t4S011312; Wed, 27 Aug 2014 18:00:55 -0400
Received: from ex13amer-00-ah.ad.mathworks.com (ex13amer-00-ah.ad.mathworks.com [172.31.154.20]) by mail-vif.mathworks.com (8.13.8/8.13.8) with ESMTP id s7RM0fHC010954; Wed, 27 Aug 2014 18:00:55 -0400 (EDT)
Received: from ex13amer-01-ah.ad.mathworks.com (172.31.154.21) by ex13amer-00-ah.ad.mathworks.com (172.31.154.20) with Microsoft SMTP Server (TLS) id 15.0.913.22; Wed, 27 Aug 2014 18:00:23 -0400
Received: from ex13amer-01-ah.ad.mathworks.com ([fe80::ecba:5f2:794:cc33]) by ex13amer-01-ah.ad.mathworks.com ([fe80::ecba:5f2:794:cc33%22]) with mapi id 15.00.0913.011; Wed, 27 Aug 2014 18:00:23 -0400
Delivered-To: cpan-bug+PathTools [...] hipster.bestpractical.com
Subject: Cwd::abs_path modifies cwd on Windows drive being queried
Return-Path: <Greg.Aloe [...] mathworks.com>
Thread-Index: Ac/CPyicrqN3179tRCS/BP4QG/N7CA==
X-RT-Mail-Extension: pathtools
X-Original-To: cpan-bug+PathTools [...] hipster.bestpractical.com
X-Spam-Check-BY: la.mx.develooper.com
Date: Wed, 27 Aug 2014 22:00:22 +0000
X-Spam-Level:
X-MS-Has-Attach:
Thread-Topic: Cwd::abs_path modifies cwd on Windows drive being queried
X-Originating-Ip: [172.31.39.101]
Accept-Language: en-US
To: "bug-PathTools [...] rt.cpan.org" <bug-PathTools [...] rt.cpan.org>
From: Greg Aloe <Greg.Aloe [...] mathworks.com>
X-RT-Interface: Email
Content-Length: 0
content-type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-RT-Original-Encoding: ascii
Content-Length: 2390
Download (untitled) / with headers
text/plain 2.3k
Here's a code snippet from Cwd::abs_path: if (!CORE::chdir($path)) { _croak("Cannot chdir to $path: $!"); } my $realpath = getcwd(); if (! ((-d $cwd) && (CORE::chdir($cwd)))) { _croak("Cannot chdir back to $cwd: $!"); } In this code, there's an attempt to chdir to the path being queried. Then there's an attempt to chdir back to the original cwd. If there are no errors (the usual happy case), then the cwd for the drive of the queried path gets unexpectedly modified. Consider the case where your cwd is H:\home and the path being queried is C:\Temp\blah. If my current Windows C drive is C:\Work\User, then a call to Cwd::abs_path('C:\\Temp\\blah') will actually change the current Windows C drive to that. The subsequent attempt to restore back to H:\home is successful. However, if I then query my current Windows C drive, it's no longer C:\Work\User. Here's a live example where the path being queried is subsequently deleted, but the original current path on the same Windows drive still exists: use Cwd; my $hcwd = "H:\\home\\"; my $ccwd = "C:\\Work\\User"; my $temp = "C:\\Temp\\blahblehblih"; mkdir $temp; chdir($ccwd); chdir($hcwd); print "Found C: before abs_path\n" if -d 'C:'; abs_path($temp); rmdir($temp); print "Could not find C: after abs_path and rmdir\n" if !-d 'C:'; You might think it's crazy to work with current Windows drives, but I found this to be a root cause in my own code's usage of File::Copy::Recursive. Therefore, I've copied Daniel to let him know about a related bug as well. The pathmk routine splits a Windows path resulting in a list like this: ('C:', 'Temp', 'blahbleblih'). When iterating over that list and checking for the existence of each segment, you might find that a check for -d 'C:' returns undef! This is a separate bug in itself regardless of whether abs_path was used or not. I will report that separately. Here's the code with that bug: sub pathmk { my @parts = File::Spec->splitdir( shift() ); my $nofatal = shift; my $pth = $parts[0]; my $zer = 0; if(!$pth) { $pth = File::Spec->catdir($parts[0],$parts[1]); $zer = 1; } for($zer..$#parts) { mkdir $pth or return if !-d $pth && !$nofatal; mkdir $pth if !-d $pth && $nofatal; $pth = File::Spec->catdir($pth, $parts[$_ + 1]) unless $_ == $#parts; } 1; } Greg
content-type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-RT-Original-Encoding: ascii
Content-Length: 6345


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.