aboutsummaryrefslogtreecommitdiff
path: root/projects/gdal
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@mines-paris.org>2017-06-15 17:37:04 +0200
committerAbhishek Arya <inferno@chromium.org>2017-06-15 08:37:04 -0700
commit606d84b729cea785b2b51dcde0c1ddb3995f89fe (patch)
treee173c5405b324ddcf759f43082dd94866521394b /projects/gdal
parent3cee68fa11da64856e59de22a59cf84ce90dfa72 (diff)
downloadoss-fuzz-606d84b729cea785b2b51dcde0c1ddb3995f89fe.tar.gz
GDAL: add libcurl dependency (#677)
* GDAL: add libcurl dependency * GDAL: move download of curl and netcdf sources in Dockerfile * GDAL: add patch for libnetcdf This fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2265 Patch submitted in libnetcdf upstream per https://github.com/Unidata/netcdf-c/pull/427
Diffstat (limited to 'projects/gdal')
-rw-r--r--projects/gdal/Dockerfile18
-rwxr-xr-xprojects/gdal/build.sh18
-rw-r--r--projects/gdal/libnetcdf_fix_undefined_left_shift_in_ncx_get_size_t.patch22
3 files changed, 51 insertions, 7 deletions
diff --git a/projects/gdal/Dockerfile b/projects/gdal/Dockerfile
index b9396a8df..c41b69e92 100644
--- a/projects/gdal/Dockerfile
+++ b/projects/gdal/Dockerfile
@@ -16,9 +16,23 @@
FROM gcr.io/oss-fuzz-base/base-builder
MAINTAINER even.rouault@spatialys.com
-RUN apt-get update && apt-get install -y make autoconf automake libtool g++ zlib1g-dev libsqlite3-dev libexpat-dev liblzma-dev libxerces-c-dev libpng12-dev libgif-dev libwebp-dev libicu-dev libnetcdf-dev curl cmake
+RUN apt-get update && apt-get install -y make autoconf automake libtool g++ zlib1g-dev libsqlite3-dev libexpat-dev liblzma-dev libxerces-c-dev libpng12-dev libgif-dev libwebp-dev libicu-dev libnetcdf-dev curl cmake libssl-dev
# libgeos-dev libjpeg-dev libcurl4-gnutls-dev libproj-dev libxml2-dev netcdf-bin libpoppler-dev libspatialite-dev libhdf4-alt-dev libhdf5-serial-dev poppler-utils libfreexl-dev unixodbc-dev libepsilon-dev libpcre3-dev
# libpodofo-dev libcrypto++-dev
RUN git clone --depth 1 https://github.com/OSGeo/gdal gdal
+
+RUN git clone --depth 1 https://github.com/curl/curl.git gdal/curl
+
+COPY build.sh NC4_put_propattr_leak_fix.patch libnetcdf_fix_undefined_left_shift_in_ncx_get_size_t.patch $SRC/
+
+RUN curl ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.4.1.1.tar.gz > gdal/netcdf-4.4.1.1.tar.gz && \
+ cd gdal && \
+ tar xzf netcdf-4.4.1.1.tar.gz && \
+ rm -f netcdf-4.4.1.1.tar.gz && \
+ cd netcdf-4.4.1.1 && \
+ patch -p0 < $SRC/NC4_put_propattr_leak_fix.patch && \
+ patch -p0 < $SRC/libnetcdf_fix_undefined_left_shift_in_ncx_get_size_t.patch && \
+ cd ../..
+
WORKDIR gdal
-COPY build.sh NC4_put_propattr_leak_fix.patch $SRC/
+
diff --git a/projects/gdal/build.sh b/projects/gdal/build.sh
index c1f7b5660..69a30cd97 100755
--- a/projects/gdal/build.sh
+++ b/projects/gdal/build.sh
@@ -15,12 +15,18 @@
#
################################################################################
+# build libcurl.a (builing against Ubuntu libcurl.a doesn't work easily)
+cd curl
+./buildconf
+./configure --disable-shared --prefix=$SRC/install
+make clean -s
+make -j$(nproc) -s
+make install
+cd ..
+
# build libnetcdf.a
-curl ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.4.1.1.tar.gz > netcdf-4.4.1.1.tar.gz
-tar xzf netcdf-4.4.1.1.tar.gz
cd netcdf-4.4.1.1
-patch -p0 < $SRC/NC4_put_propattr_leak_fix.patch
-mkdir build
+mkdir -p build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$SRC/install -DHDF5_C_LIBRARY=libhdf5_serial.a -DHDF5_HL_LIBRARY=libhdf5_serial_hl.a -DHDF5_INCLUDE_DIR=/usr/include/hdf5/serial -DENABLE_DAP:BOOL=OFF -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_UTILITIES:BOOL=OFF -DBUILD_TESTING:BOOL=OFF -DENABLE_TESTS:BOOL=OFF
make clean -s
@@ -31,7 +37,7 @@ cd ../..
# build gdal
cd gdal
export LDFLAGS=${CXXFLAGS}
-./configure --without-libtool --with-liblzma --with-expat --with-sqlite3 --with-xerces --with-webp --with-netcdf=$SRC/install --without-curl --without-hdf5 --with-jpeg=internal
+./configure --without-libtool --with-liblzma --with-expat --with-sqlite3 --with-xerces --with-webp --with-netcdf=$SRC/install --with-curl=$SRC/install --without-hdf5 --with-jpeg=internal
make clean -s
make -j$(nproc) -s static-lib
@@ -40,6 +46,8 @@ export EXTRA_LIBS="-Wl,-Bstatic -lwebp -llzma -lexpat -lsqlite3 -lgif -lpng12 -l
export EXTRA_LIBS="$EXTRA_LIBS -lxerces-c -licuuc -licudata"
# netCDF related
export EXTRA_LIBS="$EXTRA_LIBS -L$SRC/install/lib -lnetcdf -lhdf5_serial_hl -lhdf5_serial -lsz -laec -lz"
+# curl related
+export EXTRA_LIBS="$EXTRA_LIBS -L$SRC/install/lib -lcurl -lssl -lcrypto -lz"
export EXTRA_LIBS="$EXTRA_LIBS -Wl,-Bdynamic -ldl -lpthread"
./fuzzers/build_google_oss_fuzzers.sh
./fuzzers/build_seed_corpus.sh
diff --git a/projects/gdal/libnetcdf_fix_undefined_left_shift_in_ncx_get_size_t.patch b/projects/gdal/libnetcdf_fix_undefined_left_shift_in_ncx_get_size_t.patch
new file mode 100644
index 000000000..aec263945
--- /dev/null
+++ b/projects/gdal/libnetcdf_fix_undefined_left_shift_in_ncx_get_size_t.patch
@@ -0,0 +1,22 @@
+--- libsrc/ncx.m4.ori 2017-06-15 12:45:29.461345214 +0200
++++ libsrc/ncx.m4 2017-06-15 12:45:42.593332765 +0200
+@@ -1883,7 +1883,7 @@
+ /* similar to get_ix_int */
+ const uchar *cp = (const uchar *) *xpp;
+
+- *ulp = (unsigned)(*cp++ << 24);
++ *ulp = (unsigned)(*cp++) << 24;
+ *ulp |= (*cp++ << 16);
+ *ulp |= (*cp++ << 8);
+ *ulp |= *cp;
+--- libsrc/ncx.c.ori 2017-06-15 12:38:29.769770935 +0200
++++ libsrc/ncx.c 2017-06-15 12:41:15.861594817 +0200
+@@ -3451,7 +3451,7 @@
+ /* similar to get_ix_int */
+ const uchar *cp = (const uchar *) *xpp;
+
+- *ulp = (unsigned)(*cp++ << 24);
++ *ulp = (unsigned)(*cp++) << 24;
+ *ulp |= (*cp++ << 16);
+ *ulp |= (*cp++ << 8);
+ *ulp |= *cp;