summaryrefslogtreecommitdiff
path: root/pp_pack.c
diff options
context:
space:
mode:
authorTon Hospel <perl5-porters@ton.iguana.be>2005-01-29 13:24:55 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-02-02 19:23:46 +0000
commitd6d3e8bddad8c105fc1972d4d9a8298ad3f73f11 (patch)
tree9f82d6d3b409beff95ecbff08f8591c5aa381157 /pp_pack.c
parent6309100e80203b1dd76aa4be8a42b20fb0415252 (diff)
downloadperl-d6d3e8bddad8c105fc1972d4d9a8298ad3f73f11.tar.gz
Re: encoding neutral unpack
From: perl5-porters[at]ton.iguana.be (Ton Hospel) Message-ID: <ctg2r7$j0e$4[at]post.home.lunix> Ensure that with the C format, unpack checksums don't get overflowed. (plus a regression test) p4raw-id: //depot/perl@23922
Diffstat (limited to 'pp_pack.c')
-rw-r--r--pp_pack.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/pp_pack.c b/pp_pack.c
index cb3dd89cbe..97e0a06fac 100644
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -1183,7 +1183,10 @@ S_unpack_rec(pTHX_ register tempsym_t* symptr, register char *s, char *strbeg, c
uchar_checksum:
while (len-- > 0) {
auint = *s++ & 255;
- cuv += auint;
+ if (checksum > bits_in_uv)
+ cdouble += (NV)auint;
+ else
+ cuv += auint;
}
}
else {
@@ -1703,7 +1706,7 @@ S_unpack_rec(pTHX_ register tempsym_t* symptr, register char *s, char *strbeg, c
if (checksum) {
if (strchr("fFdD", TYPE_NO_MODIFIERS(datumtype)) ||
(checksum > bits_in_uv &&
- strchr("csSiIlLnNUvVqQjJ", TYPE_NO_MODIFIERS(datumtype))) ) {
+ strchr("cCsSiIlLnNUvVqQjJ", TYPE_NO_MODIFIERS(datumtype))) ) {
NV trouble;
adouble = (NV) (1 << (checksum & 15));