Opened 14 years ago

Closed 5 years ago

#3400 closed defect (wontfix)

Fix rare divide by zero in JPEG

Reported by: gaige Owned by: warmerdam
Priority: normal Milestone: closed_because_of_github_migration
Component: GDAL_Raster Version: svn-trunk
Severity: normal Keywords:
Cc:

Description

Under very rare circumstances, the quantification routines can divide by zero. Checking for zero resolves that.

jpeg/libjpeg/jquant2.c:

532,534c532,540
<   cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total);
<   cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total);
<   cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total);
---
>   if (total>0) {
> 	  cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total);
> 	  cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total);
> 	  cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total);
>   } else {
> 	  cinfo->colormap[0][icolor] = (JSAMPLE) 0;
> 	  cinfo->colormap[1][icolor] = (JSAMPLE) 0;
> 	  cinfo->colormap[2][icolor] = (JSAMPLE) 0;
>   }

Change History (5)

comment:1 by gaige, 14 years ago

Component: defaultGDAL_Raster

comment:2 by warmerdam, 14 years ago

Milestone: 1.7.1
Status: newassigned

Gaige,

Would you be willing to file this issue with the libjpeg project at sourceforge, and also provide an example of how to reproduce the problem that is being fixed? Once it is fixed upstream, I can pull down the fix into GDAL.

http://sourceforge.net/tracker/?group_id=159521&atid=812162

comment:3 by Jukka Rahkonen, 9 years ago

Can anybody tell if this is fixed in libjpeg?

in reply to:  3 comment:4 by Even Rouault, 9 years ago

Replying to jratike80:

Can anybody tell if this is fixed in libjpeg?

No, unfixed in libjpeg. A way to reproduce the problem would be a first step

comment:5 by Even Rouault, 5 years ago

Milestone: closed_because_of_github_migration
Resolution: wontfix
Status: assignedclosed

This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub. If you believe this ticket is still valid, you may file it to https://github.com/OSGeo/gdal/issues if it is not already reported there.

Note: See TracTickets for help on using tickets.