This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
utf8n_to_uvchr(): Reduce chances of reading beyond buffer
authorKarl Williamson <khw@cpan.org>
Thu, 20 Oct 2016 03:20:48 +0000 (21:20 -0600)
committerKarl Williamson <khw@cpan.org>
Thu, 20 Oct 2016 03:32:13 +0000 (21:32 -0600)
commit3cc6a05eedade6f51526feb18c12356b0589d77a
treefd4a087fd5513b9149a6f3bfe1627c75e7e41737
parent14c482b0d8b7402f1b2b28d2918a55c83577d6ff
utf8n_to_uvchr(): Reduce chances of reading beyond buffer

utf8n_to_uvchr() can be called incorrectly, leading it to believe the
buffer is longer than it actually is.  But often, it will be called with
NUL terminated strings, so it can reduce it's chances of being fooled by
refusing to read beyond a NUL.  The NUL will terminate any UTF-8 byte
sequence, and the only reason to read beyond it would be to print all
the expected bytes in the sequence.

This commit is not the final word, but it is an easy fix for a common
case.
embed.fnc
proto.h
utf8.c