Fix VMS-specific wraparound error in S_mayberelocate.
authorCraig A. Berry <craigberry@mac.com>
Mon, 25 Nov 2013 00:27:00 +0000 (18:27 -0600)
committerCraig A. Berry <craigberry@mac.com>
Mon, 25 Nov 2013 00:27:00 +0000 (18:27 -0600)
In trimming the trailing slash from a Unix path spec, we haven't
(since 5.003 or so) been ensuring that we weren't stepping off
the beginning of the string.  No, it's not normal to have '/' as
a library path, but if it happens we shouldn't allow a zero or
negative (actually wraparound since unsigned) value for the path
length.

perl.c

diff --git a/perl.c b/perl.c
index 76520522425f15c2a9fe11389f7f4ee11f4bd048..827191520f1ca86ef57f708b2fed61ec746a5227 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -4529,7 +4529,7 @@ S_mayberelocate(pTHX_ const char *const dir, STRLEN len, U32 flags)
 
        if ((unix = tounixspec_ts(SvPV(libdir,len),NULL)) != NULL) {
            len = strlen(unix);
-           while (unix[len-1] == '/') len--;  /* Cosmetic */
+           while (len > 1 && unix[len-1] == '/') len--;  /* Cosmetic */
            sv_usepvn(libdir,unix,len);
        }
        else