diff options
author | David Mitchell <davem@iabyn.com> | 2014-12-22 20:12:22 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2014-12-31 11:28:52 +0000 |
commit | e68aed92f594456b596d9b3d8c0fba00406fe76d (patch) | |
tree | e15d502db43ece5dafaa95e945c3bbab52060ee9 /pp_pack.c | |
parent | fc01cab408a7f4e5d9726611998d5b9c01f727ae (diff) | |
download | perl-e68aed92f594456b596d9b3d8c0fba00406fe76d.tar.gz |
pack(): avoid << of negative values
Treat the string as U8* rather than char* when doing all the
bit shifts for uuencode. That stops these warnings under ASan:
pp_pack.c:1890:34: runtime error: left shift of negative value -127
pp_pack.c:1891:34: runtime error: left shift of negative value -126
pp_pack.c:1899:34: runtime error: left shift of negative value -1
pp_pack.c:1900:30: runtime error: left shift of negative value -31
Diffstat (limited to 'pp_pack.c')
-rw-r--r-- | pp_pack.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -1882,7 +1882,7 @@ PP(pp_unpack) } STATIC U8 * -doencodes(U8 *h, const char *s, I32 len) +doencodes(U8 *h, const U8 *s, I32 len) { *h++ = PL_uuemap[len]; while (len > 2) { @@ -1894,7 +1894,7 @@ doencodes(U8 *h, const char *s, I32 len) len -= 3; } if (len > 0) { - const char r = (len > 1 ? s[1] : '\0'); + const U8 r = (len > 1 ? s[1] : '\0'); *h++ = PL_uuemap[(077 & (s[0] >> 2))]; *h++ = PL_uuemap[(077 & (((s[0] << 4) & 060) | ((r >> 4) & 017)))]; *h++ = PL_uuemap[(077 & ((r << 2) & 074))]; @@ -3110,9 +3110,9 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) "aptr=%p, aend=%p, buffer=%p, todo=%ld", aptr, aend, buffer, (long) todo); } - end = doencodes(hunk, buffer, todo); + end = doencodes(hunk, (const U8 *)buffer, todo); } else { - end = doencodes(hunk, aptr, todo); + end = doencodes(hunk, (const U8 *)aptr, todo); aptr += todo; } PUSH_BYTES(utf8, cur, hunk, end-hunk, 0); |