diff options
author | Karl Williamson <khw@cpan.org> | 2018-07-01 22:39:47 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2019-03-08 12:41:03 -0700 |
commit | fd879d933c2a2ee22ac6e2462acc016aa033854d (patch) | |
tree | 9d38a5e31c22c1eb84ee2d95d642a7026aa45da6 /pp_pack.c | |
parent | 56e36cbf2fdf9d90f61690c1c3fc35af0d65e0cd (diff) | |
download | perl-fd879d933c2a2ee22ac6e2462acc016aa033854d.tar.gz |
PATCH: [perl #131642] pack returning malformed UTF-8
This patch causes pack to die rather than return malformed UTF-8. This
protects the rest of the core from unexpectedly getting malformed
inputs.
Diffstat (limited to 'pp_pack.c')
-rw-r--r-- | pp_pack.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -3149,6 +3149,21 @@ PP(pp_pack) packlist(cat, pat, patend, MARK, SP + 1); + if (SvUTF8(cat)) { + STRLEN result_len; + const char * result = SvPV_nomg(cat, result_len); + const U8 * error_pos; + + if (! is_utf8_string_loc((U8 *) result, result_len, &error_pos)) { + _force_out_malformed_utf8_message(error_pos, + (U8 *) result + result_len, + 0, /* no flags */ + 1 /* Die */ + ); + NOT_REACHED; /* NOTREACHED */ + } + } + SvSETMAGIC(cat); SP = ORIGMARK; PUSHs(cat); |