Opened 3 years ago

Closed 3 years ago

#6926 closed defect (fixed)

gdal corrupts zip file (via vsizip) by writing aux.xml into zip

Reported by: ircwaves Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: 1.11.3
Severity: normal Keywords: vsizip


Using the /vsizip interface to read from an image in a Sentinel-2 MSI L1C zip file attemps to write an 'aux.xml' file to (and thus corrupts) the input zipfile. This does not occur in GDAL 2.1.3.

In the following reproduction scenario DSZIP is a Sentinel-2 zip file, and DSBAND is a jpeg2000 raster within the zip.

cp -v $DSZIP ${DSZIP}.bkup
gdalwarp -tr 480 480 $DSBAND test.tif ;
ls -lh $DSZIP ${DSZIP}.bkup
python -c "import zipfile ; f = zipfile.ZipFile(\"$DSZIP\"); print '\n   FIRST_FILE', f.namelist()[0], '\n'"


Creating output file that is 229P x 229L.
Processing input file /vsizip/
0...10...20...30...40...50...60...70...80...90...100 - done.
-rw-rw-r-- 1 icooke staff 7713856710 Jun  7 13:00
-rw-r--r-- 1 icooke staff 7713854074 Jun  7 10:39
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/", line 770, in __init__
  File "/usr/lib/python2.7/", line 839, in _RealGetContents
    raise BadZipfile("Bad magic number for central directory")
zipfile.BadZipfile: Bad magic number for central directory

Setting the zipfile to be read-only, or using GDAL_PAM_ENABLED=No are work arounds, but not optimal.

Change History (1)

comment:1 Changed 3 years ago by Even Rouault

Resolution: fixed
Status: newclosed

In 39077:

JP2OpenJPEG: avoid PAM .aux.xml saving at open time (fixes #6926)

Note: See TracTickets for help on using tickets.