diff options
author | Gurusamy Sarathy <gsar@engin.umich.edu> | 1997-09-05 00:00:00 +0000 |
---|---|---|
committer | Tim Bunce <Tim.Bunce@ig.co.uk> | 1997-09-05 00:00:00 +0000 |
commit | e8bab1813b356a0528cd91b657634bace649cd18 (patch) | |
tree | 6fe35d2710be25a1024502ba6db20c0aeeff9779 /win32 | |
parent | c578f5e04970af2516f26d023e8797da5451c90c (diff) | |
download | perl-e8bab1813b356a0528cd91b657634bace649cd18.tar.gz |
Bug in Win32::GetShortPathName
On Thu, 09 Oct 1997 08:30:55 PDT, "Greg Chapman" wrote:
>I'm using Perl 5.004_02 under WIndows 95 (the latest binary distribution
>available on CPAN). The Win32::GetShortPathName function does not properly
>truncate the returned string when the short file name is shorter than the
>long name. Specifically, the returned string looks like:
><ShortFileName><NULL char><characters from the end of the long name (the
>original buffer)>.
Thanks for that report, and here's a patch.
p5p-msgid: 199710092229.SAA21556@aatma.engin.umich.edu
Diffstat (limited to 'win32')
-rw-r--r-- | win32/win32.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/win32/win32.c b/win32/win32.c index 7a4c2852db..7cbfae8a83 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1564,6 +1564,7 @@ XS(w32_GetShortPathName) { dXSARGS; SV *shortpath; + DWORD len; if(items != 1) croak("usage: Win32::GetShortPathName($longPathName)"); @@ -1571,8 +1572,15 @@ XS(w32_GetShortPathName) shortpath = sv_mortalcopy(ST(0)); SvUPGRADE(shortpath, SVt_PV); /* src == target is allowed */ - if (GetShortPathName(SvPVX(shortpath), SvPVX(shortpath), SvCUR(shortpath))) + do { + len = GetShortPathName(SvPVX(shortpath), + SvPVX(shortpath), + SvLEN(shortpath)); + } while (len >= SvLEN(shortpath) && sv_grow(shortpath,len+1)); + if (len) { + SvCUR_set(shortpath,len); ST(0) = shortpath; + } else ST(0) = &sv_undef; XSRETURN(1); |