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
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.