diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8128f03 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM ubuntu:22.04 + +# Needed in case tzdata gets upgraded +ENV TZ=Australia/Brisbane +ARG DEBIAN_FRONTEND=noninteractive + +# Use Aussie mirrors +RUN sed -i 's/http:\/\/archive./http:\/\/au.archive./g' /etc/apt/sources.list + +# Update Ubuntu software stack and install base GDAL stack +RUN apt-get update +RUN apt-get upgrade -y +RUN apt-get install -y wget g++ cmake libhdf5-dev libgdal-dev gdal-bin + +RUN apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* + +COPY . /tmp/kealib +RUN cd /tmp/kealib \ + && mkdir build \ + && cd build \ + && cmake -D LIBKEA_WITH_GDAL=ON .. \ + && make \ + && make install \ + && cd ../.. \ + && rm -rf kealib + +ENV LD_LIBRARY_PATH=/usr/local/lib +ENV GDAL_DRIVER_PATH=/usr/local/lib/gdalplugins + +RUN gdal_translate --formats | grep KEA diff --git a/gdal/keadataset.cpp b/gdal/keadataset.cpp index 24ce2b7..370e541 100644 --- a/gdal/keadataset.cpp +++ b/gdal/keadataset.cpp @@ -32,6 +32,7 @@ #include "keacopy.h" #include "libkea/KEACommon.h" +#include "cpl_vsi_virtual.h" // Function for converting a libkea type into a GDAL type GDALDataType KEA_to_GDAL_Type( kealib::KEADataType ekeaType ) @@ -166,6 +167,14 @@ GDALDataset *KEADataset::Open( GDALOpenInfo * poOpenInfo ) poOpenInfo->pszFilename, e.what() ); return nullptr; } + catch (...) + { + // was a problem - can't be a valid file + CPLError(CE_Failure, CPLE_OpenFailed, + "Attempt to open file `%s' failed. Error: unknown\n", + poOpenInfo->pszFilename); + return nullptr; + } } else { @@ -208,6 +217,20 @@ GDALDataset *KEADataset::Create( const char * pszFilename, "Attempt to create file `%s' failed. Invalid creation option(s)\n", pszFilename); return nullptr; } + + // This helps avoiding issues with H5File handles in a bad state, that + // may cause crashes at process termination + // Cf https://github.com/OSGeo/gdal/issues/8743 + if (VSIFileManager::GetHandler(pszFilename) != + VSIFileManager::GetHandler("")) + { + CPLError(CE_Failure, CPLE_OpenFailed, + "Attempt to create file `%s' failed. /vsi file systems not " + "supported\n", + pszFilename); + return nullptr; + } + // process any creation options in papszParmList // default value unsigned int nimageblockSize = kealib::KEA_IMAGE_CHUNK_SIZE; @@ -296,6 +319,13 @@ GDALDataset *KEADataset::Create( const char * pszFilename, pszFilename, e.what() ); return nullptr; } + catch (...) + { + CPLError(CE_Failure, CPLE_OpenFailed, + "Attempt to create file `%s' failed. Error: unknown\n", + pszFilename); + return nullptr; + } } GDALDataset *KEADataset::CreateCopy( const char * pszFilename, GDALDataset *pSrcDs,