From 12cad9bd99725bba72029e2651b2b7f0cab2e0b0 Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Mon, 20 Aug 2018 16:31:45 +1000 Subject: (perl #132655) nul terminate result of unpack "u" of invalid data In the given test case, Perl_atof2() would run off the end of the PV, producing an error from ASAN. --- pp_pack.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'pp_pack.c') diff --git a/pp_pack.c b/pp_pack.c index 5e9cc64301..f8be9d48ae 100644 --- a/pp_pack.c +++ b/pp_pack.c @@ -1727,7 +1727,10 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c if (!checksum) { const STRLEN l = (STRLEN) (strend - s) * 3 / 4; sv = sv_2mortal(newSV(l)); - if (l) SvPOK_on(sv); + if (l) { + SvPOK_on(sv); + *SvEND(sv) = '\0'; + } } /* Note that all legal uuencoded strings are ASCII printables, so -- cgit v1.2.1