Skip to content

Commit

Permalink
Fixed a potential integer overflow problem in the
Browse files Browse the repository at this point in the history
jas_safeui32_to_intfast32 function.
  • Loading branch information
mdadams committed Dec 1, 2023
1 parent 917f770 commit 2bd1657
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/libjasper/include/jasper/jas_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ inline static bool jas_safe_uint_mul(unsigned x, unsigned y, unsigned *result)
* Safe 32-bit unsigned integer arithmetic (i.e., with overflow checking).
\******************************************************************************/

#define JAS_SAFEUI32_MAX (0xffffffffU)
#define JAS_SAFEUI32_MAX (0xffffffffUL)

typedef struct {
bool valid;
Expand All @@ -432,7 +432,8 @@ JAS_ATTRIBUTE_PURE
static inline bool jas_safeui32_to_intfast32(jas_safeui32_t x,
int_fast32_t* y)
{
if (x.value <= INT_FAST32_MAX) {
const long I32_MAX = 0x7fffffffL;
if (x.value <= I32_MAX) {
*y = x.value;
return true;
} else {
Expand Down

0 comments on commit 2bd1657

Please sign in to comment.