AWARE [SYSTEMS]
AWare Systems, , Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
June 2017

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



New Datamatrix section



Valid HTML 4.01!



Thread

2017.06.27 13:16 "Double to float conversion is not always valid", by Nicolas Ruff
2017.06.27 13:44 "Re: Double to float conversion is not always valid", by Even Rouault

2017.06.27 13:16 "Double to float conversion is not always valid", by Nicolas Ruff

Hello,

ASAN/UBSAN will flag the following operation in tif_dirread.c as a
"float-cast-overflow" - which is true, a double cannot always fit into a
float. I suggest the following fix:

case TIFF_DOUBLE:
{
  double m;
  err=TIFFReadDirEntryCheckedDouble(tif,direntry,&m);
  if (err!=TIFFReadDirEntryErrOk)
    return(err);
+ if ((m > FLT_MAX) || (m < FLT_MIN))
+   return(TIFFReadDirEntryErrRange);
  *value=(float)m;
  return(TIFFReadDirEntryErrOk);
}

WDYT?

Regards,
- Nicolas RUFF