GraphicsMagick: _Gm_convert_fp32_to_fp24(): Coverity fixes for a...
GraphicsMagick Commits <[email protected]> Thu, 18 Jul 2024 11:22:31 -0500
| Newsgroups | gmane.comp.video.graphicsmagick.cvs |
|---|---|
| Message-ID | <mailman.2743.1721319764.7812.graphicsmagick-commit@lists.sourceforge.net> |
changeset df8e069aaaa8 in /hg/GraphicsMagick details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=df8e069aaaa8 summary: _Gm_convert_fp32_to_fp24(): Coverity fixes for arithmetic overflow in mantissa related code. diffstat: ChangeLog | 5 +++++ VisualMagick/installer/inc/version.isx | 4 ++-- magick/floats.c | 24 ++++++++++++------------ magick/version.h | 4 ++-- www/ChangeLog.html | 7 +++++++ 5 files changed, 28 insertions(+), 16 deletions(-) diffs (138 lines): diff -r 806b1c07f221 -r df8e069aaaa8 ChangeLog --- a/ChangeLog Sun Jul 14 18:29:09 2024 -0500 +++ b/ChangeLog Thu Jul 18 11:21:57 2024 -0500 @@ -1,3 +1,8 @@ +2024-07-18 Bob Friesenhahn <[email protected]> + + * magick/floats.c (_Gm_convert_fp32_to_fp24): Coverity fixes for + arithmetic overflow in mantissa related code. + 2024-07-14 Bob Friesenhahn <[email protected]> * fuzzing/oss-fuzz-build.sh: Added support for building libzip. diff -r 806b1c07f221 -r df8e069aaaa8 VisualMagick/installer/inc/version.isx --- a/VisualMagick/installer/inc/version.isx Sun Jul 14 18:29:09 2024 -0500 +++ b/VisualMagick/installer/inc/version.isx Thu Jul 18 11:21:57 2024 -0500 @@ -10,5 +10,5 @@ #define public MagickPackageName "GraphicsMagick" #define public MagickPackageVersion "1.4" -#define public MagickPackageVersionAddendum ".020240714" -#define public MagickPackageReleaseDate "snapshot-20240714" +#define public MagickPackageVersionAddendum ".020240718" +#define public MagickPackageReleaseDate "snapshot-20240718" diff -r 806b1c07f221 -r df8e069aaaa8 magick/floats.c --- a/magick/floats.c Sun Jul 14 18:29:09 2024 -0500 +++ b/magick/floats.c Thu Jul 18 11:21:57 2024 -0500 @@ -657,7 +657,7 @@ unsigned char m1; /* low order bits of mantissa */ unsigned char new_m2, new_m1; signed short new_expt; - unsigned int mant, new_mant; + magick_uint64_t mant, new_mant; /* Mantissa, with rounding */ unsigned char *mp; unsigned char *src; unsigned char *dst; @@ -713,7 +713,7 @@ } #endif /* !defined(WORDS_BIGENDIAN) */ - mant = (m3 << 24) | (m2 << 16) |( m1 << 8); + mant = ((magick_uint64_t) m3 << 24) | (m2 << 16) |( m1 << 8); if (expt != 0) new_expt = expt - 127 + 63; @@ -805,14 +805,14 @@ /* Round up to next higher value of LSB */ for (i = 16; i < 32; i++) { - bit = mant & (1 << i); + bit = mant & ((magick_uint64_t) 1U << i); if (bit == 0) { /* Round up by inserting a 1 at first zero and * clearing bits to the right */ - new_mant = (mant | ((unsigned int)1 << i)) & - (0xFFFFU << i); + new_mant = (mant | ((magick_uint64_t) 1 << i)) & + ((magick_uint64_t) 0xFFFFU << i); mp = (unsigned char *)&new_mant; break; } @@ -825,11 +825,11 @@ /* Round up to next higher value of LSB */ for (i = 16; i < 32; i++) { - bit = mant & (1 << i); + bit = mant & ((magick_uint64_t) 1 << i); if (bit == 0) { - new_mant = (mant | ((unsigned int)1 << i)) & - (0xFFFFU << i); + new_mant = (mant | ((magick_uint64_t) 1 << i)) & + ((magick_uint64_t) 0xFFFFU << i); mp = (unsigned char *)&new_mant; break; } @@ -863,7 +863,7 @@ printf ("%10.10f mant%s ", *fp32, (rbits & 0x8000) ? "+" : "-"); for (j = 0, k = 31; j < 23; j++, k--) { - bit = mant & (1 << k); + bit = mant & ((magick_uint64_t) 1 << k); if ((j % 8) == 0) printf(" "); printf ("%d", bit ? 1 : 0); @@ -927,7 +927,7 @@ #endif /* !defined(WORDS_BIGENDIAN) */ printf ("\n"); - mant = ((unsigned int)new_m2 << 8) | (unsigned int)new_m1; + mant = ((magick_uint64_t)new_m2 << 8) | (magick_uint64_t)new_m1; if (*fp32 == 0.0) { test = 0.0; @@ -939,9 +939,9 @@ accum = 0.0; for (i = 15, j = 1; i >= 0; i--, j++) { - bit = mant & ((unsigned int)1 << i); + bit = mant & ((magick_uint64_t)1 << i); if (bit) - accum += (1.0 / ((unsigned int)1 << j)); + accum += (1.0 / ((magick_uint64_t)1 << j)); } if (new_expt != 0) accum += 1.0; diff -r 806b1c07f221 -r df8e069aaaa8 magick/version.h --- a/magick/version.h Sun Jul 14 18:29:09 2024 -0500 +++ b/magick/version.h Thu Jul 18 11:21:57 2024 -0500 @@ -38,8 +38,8 @@ #define MagickLibVersion 0x282500 #define MagickLibVersionText "1.4" #define MagickLibVersionNumber 28,25,0 -#define MagickChangeDate "20240714" -#define MagickReleaseDate "snapshot-20240714" +#define MagickChangeDate "20240718" +#define MagickReleaseDate "snapshot-20240718" /* The MagickLibInterfaceNewest and MagickLibInterfaceOldest defines diff -r 806b1c07f221 -r df8e069aaaa8 www/ChangeLog.html --- a/www/ChangeLog.html Sun Jul 14 18:29:09 2024 -0500 +++ b/www/ChangeLog.html Thu Jul 18 11:21:57 2024 -0500 @@ -38,6 +38,13 @@ <main id="graphicsmagick-changelog"> <h1 class="title">GraphicsMagick ChangeLog</h1> +<p>2024-07-18 Bob Friesenhahn <<a class="reference external" href="mailto:bfriesen%40simple.dallas.tx.us">bfriesen<span>@</span>simple<span>.</span>dallas<span>.</span>tx<span>.</span>us</a>></p> +<blockquote> +<ul class="simple"> +<li><p>magick/floats.c (_Gm_convert_fp32_to_fp24): Coverity fixes for +arithmetic overflow in mantissa related code.</p></li> +</ul> +</blockquote> <p>2024-07-14 Bob Friesenhahn <<a class="reference external" href="mailto:bfriesen%40simple.dallas.tx.us">bfriesen<span>@</span>simple<span>.</span>dallas<span>.</span>tx<span>.</span>us</a>></p> <blockquote> <ul class="simple">