Integrate:
authorJarkko Hietaniemi <jhi@iki.fi>
Thu, 20 Mar 2003 05:23:15 +0000 (05:23 +0000)
committerJarkko Hietaniemi <jhi@iki.fi>
Thu, 20 Mar 2003 05:23:15 +0000 (05:23 +0000)
[ 19033]
file test operators weren't doing the right thing if the SV
passed to them wasn't NUL-terminated

[ 19034]
ensure SVs returned by Win32::Get{Short,Full}PathName() are
NUL-terminated
p4raw-link: @19034 on //depot/maint-5.6/perl: d453a28c5f70420dd114c2f0f61ec1aaf34109e0
p4raw-link: @19033 on //depot/maint-5.6/perl: 1ad7974d3a92321c870ce2bd5ce4e57098b51c10

p4raw-id: //depot/perl@19036
p4raw-integrated: from //depot/maint-5.6/perl@19028 'merge in' doio.c
(@16333..) win32/win32.c (@18377..)

doio.c
win32/win32.c

diff --git a/doio.c b/doio.c
index 091e02b..a1cc42a 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -1321,7 +1321,7 @@ Perl_my_stat(pTHX)
     else {
        SV* sv = POPs;
        char *s;
-       STRLEN n_a;
+       STRLEN len;
        PUTBACK;
        if (SvTYPE(sv) == SVt_PVGV) {
            gv = (GV*)sv;
@@ -1332,9 +1332,10 @@ Perl_my_stat(pTHX)
            goto do_fstat;
        }
 
-       s = SvPV(sv, n_a);
+       s = SvPV(sv, len);
        PL_statgv = Nullgv;
-       sv_setpv(PL_statname, s);
+       sv_setpvn(PL_statname, s, len);
+       s = SvPVX(PL_statname);         /* s now NUL-terminated */
        PL_laststype = OP_STAT;
        PL_laststatval = PerlLIO_stat(s, &PL_statcache);
        if (PL_laststatval < 0 && ckWARN(WARN_NEWLINE) && strchr(s, '\n'))
index 070ee9c..87665ff 100644 (file)
@@ -4647,6 +4647,7 @@ XS(w32_GetShortPathName)
     } while (len >= SvLEN(shortpath) && sv_grow(shortpath,len+1));
     if (len) {
        SvCUR_set(shortpath,len);
+       *SvEND(shortpath) = '\0';
        ST(0) = shortpath;
        XSRETURN(1);
     }
@@ -4690,6 +4691,7 @@ XS(w32_GetFullPathName)
            items = 2;
        }
        SvCUR_set(fullpath,len);
+       *SvEND(fullpath) = '\0';
        ST(0) = fullpath;
        XSRETURN(items);
     }