This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Replace utf8_to_uvchr() with a safer version
authorKarl Williamson <khw@cpan.org>
Fri, 19 Apr 2019 19:25:56 +0000 (13:25 -0600)
committerKarl Williamson <khw@cpan.org>
Sat, 20 Apr 2019 06:37:35 +0000 (00:37 -0600)
commit39d7245cccf52966c3621db75e39bbc5ac698c28
tree4e3647620d65c09fab96ca6fbe1b8221f39f5714
parent237241a7aff31f0b5f13bacc9f203e05729fec1c
Replace utf8_to_uvchr() with a safer version

This function has no parameter to tell it what the upper bound of the
input string is.  This makes it prone to reading beyond the end of the
buffer when presented with malformed UTF-8 input.

This commit lessens the chances of that by taking advantage of the fact
that the perl interpreter most often NUL terminates strings.  So the
function is rewritten to not read past a NUL.

This won't help code that's compiled to use the perl version in effect,
as that will continue to use the unsafe version, but it will help any
modules that get downloaded and recompiled using a ppport.h that
contains this commit.

The existing utf8_to_uvchr gets undefined and replaced with this safer
version.
dist/Devel-PPPort/Changes
dist/Devel-PPPort/parts/inc/uv
dist/Devel-PPPort/t/uv.t