summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2019-02-01 11:43:10 -0700
committerKarl Williamson <khw@cpan.org>2019-02-04 21:00:50 -0700
commitdbb3849a8c02c652b48b25b770fc36b743b162db (patch)
treeb7177d1a50305df54c058ecac6acb2e721e715a1 /pp.c
parent02601e33951e916a19e46272146a0b59862aaff5 (diff)
downloadperl-dbb3849a8c02c652b48b25b770fc36b743b162db.tar.gz
pp.c: Avoid use of unsafe function
The function is unsafe because it doesn't check for running off the end of the buffer if presented with illegal UTF-8. The only remaining use now is from mathoms.c.
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/pp.c b/pp.c
index 9e4c3b242a..790f82bc59 100644
--- a/pp.c
+++ b/pp.c
@@ -28,6 +28,7 @@
#include "perl.h"
#include "keywords.h"
+#include "invlist_inline.h"
#include "reentr.h"
#include "regcharclass.h"
@@ -4039,12 +4040,16 @@ PP(pp_uc)
STRLEN u;
STRLEN ulen;
UV uv;
- if (UNLIKELY(in_iota_subscript) && ! _is_utf8_mark(s)) {
+ if (UNLIKELY(in_iota_subscript)) {
+ UV cp = utf8_to_uvchr_buf(s, send, NULL);
+
+ if (! _invlist_contains_cp(PL_utf8_mark, cp)) {
/* A non-mark. Time to output the iota subscript */
*d++ = UTF8_TWO_BYTE_HI(GREEK_CAPITAL_LETTER_IOTA);
*d++ = UTF8_TWO_BYTE_LO(GREEK_CAPITAL_LETTER_IOTA);
in_iota_subscript = FALSE;
+ }
}
/* Then handle the current character. Get the changed case value