utf8 substr can access memory outside PVX buffer
authorGisle Aas <gisle@aas.no>
Wed, 14 Oct 1998 00:38:06 +0000 (02:38 +0200)
committerGurusamy Sarathy <gsar@cpan.org>
Sat, 17 Oct 1998 03:06:33 +0000 (03:06 +0000)
Message-ID: <m3iuhonl4h.fsf@furu.g.aas.no>

p4raw-id: //depot/perl@2000

sv.c

diff --git a/sv.c b/sv.c
index ad38a87..97a0790 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -3134,12 +3134,16 @@ sv_pos_u2b(register SV *sv, I32* offsetp, I32* lenp)
     send = s + len;
     while (s < send && uoffset--)
        s += UTF8SKIP(s);
+    if (s >= send)
+       s = send;
     *offsetp = s - start;
     if (lenp) {
        I32 ulen = *lenp;
        start = s;
        while (s < send && ulen--)
            s += UTF8SKIP(s);
+       if (s >= send)
+           s = send;
        *lenp = s - start;
     }
     return;