New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PATCH] Coverity: quad cannot escape its nature #13828
Comments
From @jhiA quad (or uquad) cannot be less than the (u)quad minimum or greater Patch attached. |
From @jhi0001-Quad_t-and-Uquad_t-cannot-unpack-as-NVs.patchFrom c669f8bd8f0851eff59d5c9551c6e0dda64f65a5 Mon Sep 17 00:00:00 2001
From: Jarkko Hietaniemi <jhi@iki.fi>
Date: Tue, 6 May 2014 12:50:55 -0400
Subject: [PATCH] Quad_t and Uquad_t cannot unpack as NVs.
If IVSIZE >= 8, a Quad_t is always >= IV_MIN, and <= IV_MAX, and an
Uquad_t is always (>= 0 aka UV_MIN and) <= UV_MAX; they cannot escape
their quadness and be NVs. (This logic may fail if Quad_t is not 8
bytes, but then other things would no doubt fail.)
Also tighten the logic by adding HAS_QUAD, also for the pack case.
Fix for Coverity perl5 CID 28942.
---
pp_pack.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/pp_pack.c b/pp_pack.c
index 3aa7a73..e4211b1 100644
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -1632,14 +1632,13 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c
PUSHs(newSVpvn_flags(aptr, len, SVs_TEMP));
}
break;
-#if IVSIZE >= 8
+#if defined(HAS_QUAD) && IVSIZE >= 8
case 'q':
while (len-- > 0) {
Quad_t aquad;
SHIFT_VAR(utf8, s, strend, aquad, datumtype, needs_swap);
if (!checksum)
- mPUSHs(aquad >= IV_MIN && aquad <= IV_MAX ?
- newSViv((IV)aquad) : newSVnv((NV)aquad));
+ mPUSHs(newSViv((IV)aquad));
else if (checksum > bits_in_uv)
cdouble += (NV)aquad;
else
@@ -1651,8 +1650,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c
Uquad_t auquad;
SHIFT_VAR(utf8, s, strend, auquad, datumtype, needs_swap);
if (!checksum)
- mPUSHs(auquad <= UV_MAX ?
- newSVuv((UV)auquad) : newSVnv((NV)auquad));
+ mPUSHs(newSVuv((UV)auquad));
else if (checksum > bits_in_uv)
cdouble += (NV)auquad;
else
@@ -2982,7 +2980,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist )
PUSH32(utf8, cur, &ai32, needs_swap);
}
break;
-#if IVSIZE >= 8
+#if defined(HAS_QUAD) && IVSIZE >= 8
case 'Q':
while (len-- > 0) {
Uquad_t auquad;
--
1.9.2
|
The RT System itself - Status changed from 'new' to 'open' |
@tonycoz - Status changed from 'open' to 'resolved' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Migrated from rt.perl.org#121859 (status was 'resolved')
Searchable as RT121859$
The text was updated successfully, but these errors were encountered: