CVE-2016-10251 (published 2017-03-15T14:59Z)

Integer overflow in the jpc_pi_nextcprl function in jpc_t2cod.c in JasPer before 1.900.20 allows remote attackers to have unspecified impact via a crafted file, which triggers use of an uninitialized value.

Severity: MEDIUM
CVSS v2 base score: 6.8 (AV:N/AC:M/Au:N/C:P/I:P/A:P)
CVSS v3 base score: 7.8, HIGH (CVSS:3.0/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: CWE-190
cwe_name: Integer Overflow or Wraparound
description: The product performs a calculation that can
         produce an integer overflow or wraparound when the logic
         assumes that the resulting value will always be larger than
         the original value. This occurs when an integer value is
         incremented to a value that is too large to store in the
         associated representation. When this occurs, the value may
         become a very small or negative number.
extended_description: 
            
            
            
            
         
         

Fix information:
repo_url: https://github.com/mdadams/jasper
commit_details: repo_url: https://github.com/mdadams/jasper
author: Michael Adams
author_date: 2016-11-04 07:20:23-07:00
msg: Fixed an integer overflow problem in the JPC codec that later resulted
in the use of uninitialized data.
repository: repo_url: https://github.com/mdadams/jasper
repo_name: jasper-software/jasper
description: Official Repository for the JasPer Image Coding Toolkit
repo_language: C
owner: mdadams
file_changes: filename: jpc_t2cod.c
change_type: ModificationType.MODIFY
diff: @@ -432,18 +432,18 @@ static int jpc_pi_nextcprl(register jpc_pi_t *pi)
 	  &pi->picomps[pi->compno]; pi->compno < JAS_CAST(int, pchg->compnoend) && pi->compno < pi->numcomps; ++pi->compno,
 	  ++pi->picomp) {
 		pirlvl = pi->picomp->pirlvls;
-		pi->xstep = pi->picomp->hsamp * (1 << (pirlvl->prcwidthexpn +
-		  pi->picomp->numrlvls - 1));
-		pi->ystep = pi->picomp->vsamp * (1 << (pirlvl->prcheightexpn +
-		  pi->picomp->numrlvls - 1));
+		pi->xstep = pi->picomp->hsamp * (JAS_CAST(uint_fast32_t, 1) <<
+		  (pirlvl->prcwidthexpn + pi->picomp->numrlvls - 1));
+		pi->ystep = pi->picomp->vsamp * (JAS_CAST(uint_fast32_t, 1) <<
+		  (pirlvl->prcheightexpn + pi->picomp->numrlvls - 1));
 		for (rlvlno = 1, pirlvl = &pi->picomp->pirlvls[1];
 		  rlvlno < pi->picomp->numrlvls; ++rlvlno, ++pirlvl) {
-			pi->xstep = JAS_MIN(pi->xstep, pi->picomp->hsamp * (1 <<
-			  (pirlvl->prcwidthexpn + pi->picomp->numrlvls -
-			  rlvlno - 1)));
-			pi->ystep = JAS_MIN(pi->ystep, pi->picomp->vsamp * (1 <<
-			  (pirlvl->prcheightexpn + pi->picomp->numrlvls -
-			  rlvlno - 1)));
+			pi->xstep = JAS_MIN(pi->xstep, pi->picomp->hsamp *
+			  (JAS_CAST(uint_fast32_t, 1) << (pirlvl->prcwidthexpn +
+			  pi->picomp->numrlvls - rlvlno - 1)));
+			pi->ystep = JAS_MIN(pi->ystep, pi->picomp->vsamp *
+			  (JAS_CAST(uint_fast32_t, 1) << (pirlvl->prcheightexpn +
+			  pi->picomp->numrlvls - rlvlno - 1)));
 		}
 		for (pi->y = pi->ystart; pi->y < pi->yend;
 		  pi->y += pi->ystep - (pi->y % pi->ystep)) {

programming_language: C
filename: jpc_t2cod.h
change_type: ModificationType.MODIFY
diff: @@ -129,10 +129,10 @@ typedef struct {
 	jpc_pirlvl_t *pirlvls;
 
 	/* The horizontal sampling period. */
-	int hsamp;
+	uint_fast32_t hsamp;
 
 	/* The vertical sampling period. */
-	int vsamp;
+	uint_fast32_t vsamp;
 
 } jpc_picomp_t;
 
@@ -171,32 +171,32 @@ typedef struct {
 	int lyrno;
 
 	/* The x-coordinate of the current position. */
-	int x;
+	uint_fast32_t x;
 
 	/* The y-coordinate of the current position. */
-	int y;
+	uint_fast32_t y;
 
 	/* The horizontal step size. */
-	int xstep;
+	uint_fast32_t xstep;
 
 	/* The vertical step size. */
-	int ystep;
+	uint_fast32_t ystep;
 
 	/* The x-coordinate of the top-left corner of the tile on the reference
 	  grid. */
-	int xstart;
+	uint_fast32_t xstart;
 
 	/* The y-coordinate of the top-left corner of the tile on the reference
 	  grid. */
-	int ystart;
+	uint_fast32_t ystart;
 
 	/* The x-coordinate of the bottom-right corner of the tile on the
 	  reference grid (plus one). */
-	int xend;
+	uint_fast32_t xend;
 
 	/* The y-coordinate of the bottom-right corner of the tile on the
 	  reference grid (plus one). */
-	int yend;
+	uint_fast32_t yend;
 
 	/* The current progression change. */
 	jpc_pchg_t *pchg;

programming_language: C