Opened 15 years ago

Last modified 15 years ago

#849 closed defect (fixed)

Error to open ecw or mrsid file in GDALOpen function

Reported by: xpaytubi@… Owned by: warmerdam
Priority: high Milestone:
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords:
Cc:

Description

Hi,

I'm using a gdal cvs checkout from last week, the last ECW sources and MrSID
libraries. I've compiled the gdal and ecw library with /MDd option.

Description:
 * When I try to open a ecw or mrsid file, GDALOpen function crashes. 
Reproduction:
 * The call is  like : GDALOpen("C:\\RGBImage.ecw", GA_ReadOnly);

Causes:
 * I found that ECWDataset::Open (..) uses VSIFOpenL, and this function uses
CreateFile to obtain a handle which then is cast to a FILE*. This pointer is
used to read with fread in ReadBoxes, and this operation crashes. I think there
is a problem using the handle obtained from CreateFile for the fread function.
If I change the CreateFile function to an equivalent fopen(), then everything
seems to work correctly.

Thanks a lot.

Change History (3)

comment:1 Changed 15 years ago by xpaytubi@…

I have also to change the VSIFCloseL function, and use fclose (...) and not
CloseHandle (...).

comment:2 Changed 15 years ago by warmerdam

Xavi, 

Good job debugging!  I think the correct fix is to use VSIFReadL() 
in gdal/gcore/gdaljp2box.cpp and I have committed the corresponding change
in CVS. 

If you have a chance, could you verify that works OK for you?

On Linux the "large file" and "normal file" FILE handles are compatible, 
so it is easy for me to make mistakes and mix them.  Of course, they aren't
compatible on Win32 as you have encountered. 


comment:3 Changed 15 years ago by xpaytubi@…

Hi Frank,

I updated gdal from cvs yesterday, and I've verified it. Your fix works perfectly. 

Thanks
Note: See TracTickets for help on using tickets.