Opened 2 years ago

Closed 2 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
Cc:

Description

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'"

produces

Creating output file that is 229P x 229L.
Processing input file /vsizip/S2A_OPER_PRD_MSIL1C_PDMC_20160119T230435_R011_V20160119T155447_20160119T155447.zip/S2A_OPER_PRD_MSIL1C_PDMC_20160119T230435_R011_V20160119T155447_20160119T155447.SAFE/GRANULE/S2A_OPER_MSI_L1C_TL_SGS__20160119T194125_A003011_T18TYL_N02.01/IMG_DATA/S2A_OPER_MSI_L1C_TL_SGS__20160119T194125_A003011_T18TYL_B06.jp2.
0...10...20...30...40...50...60...70...80...90...100 - done.
-rw-rw-r-- 1 icooke staff 7713856710 Jun  7 13:00 S2A_OPER_PRD_MSIL1C_PDMC_20160119T230435_R011_V20160119T155447_20160119T155447.zip
-rw-r--r-- 1 icooke staff 7713854074 Jun  7 10:39 S2A_OPER_PRD_MSIL1C_PDMC_20160119T230435_R011_V20160119T155447_20160119T155447.zip.bkup
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/zipfile.py", line 770, in __init__
    self._RealGetContents()
  File "/usr/lib/python2.7/zipfile.py", 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 2 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.