perl-unicode

[PATCH 5.005_52] utf8 substr can access memory outside PVX buffer

1998-10-13 15:53:10
$ perl -le 'use utf8; print substr("f\374r", 1, 1)' | od -c
0000000 374   r  \0 300 322  \v  \n
0000007

This is a patch:

Index: sv.c
===================================================================
RCS file: /usr/home/aas/CVSROOT/perl_52/sv.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 sv.c
--- sv.c        1998/10/06 17:30:50     1.1.1.1
+++ sv.c        1998/10/13 22:34:33
@@ -3134,12 +3134,16 @@
     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;

<Prev in Thread] Current Thread [Next in Thread>
  • [PATCH 5.005_52] utf8 substr can access memory outside PVX buffer, Gisle Aas <=