From 6ec713109cae761394fe2142a4e68bfe475543b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20=C3=96hrstr=C3=B6m?= Date: Sat, 20 Jan 2024 17:47:20 +0100 Subject: [PATCH] Add another test for bad index file. --- autoconf/spec.mk.in | 1 + configure.ac | 4 ++-- src/index.cc | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/autoconf/spec.mk.in b/autoconf/spec.mk.in index 98689eb..3697935 100644 --- a/autoconf/spec.mk.in +++ b/autoconf/spec.mk.in @@ -49,6 +49,7 @@ CFLAGS:=@CFLAGS@ CXX:=@CXX@ CXXFLAGS_debug:=@CXXFLAGS_debug@ CXXFLAGS_release:=@CXXFLAGS_release@ +CXXFLAGS_asan:=@CXXFLAGS_asan@ CXXFLAGS:=@CXXFLAGS@ $(FUSE_CFLAGS) $(LIBNOTIFY_CFLAGS) $(OPENSSL_CFLAGS) $(ZLIB_CFLAGS) $(LIBRSYNC_CFLAGS) $(MEDIA_CFLAGS) $(PLATFORM_CFLAGS) LD:=@LD@ diff --git a/configure.ac b/configure.ac index a1d0c66..97386be 100644 --- a/configure.ac +++ b/configure.ac @@ -380,12 +380,12 @@ CXXFLAGS="-DPLATFORM_${PLATFORM} ${CXXFLAGS_EXTRAS} -D${MNEMONIC} -Wall -Wno-err CXXFLAGS_asan="-O0 -g ${ASAN_CFLAGS}" CXXFLAGS_debug="-O0 -g" -CXXFLAGS_release="-Os" +CXXFLAGS_release="-O2" LDFLAGS="" LDFLAGS_asan="-g ${ASAN_LDFLAGS} ${MEDIA_LIBS}" LDFLAGS_debug="-g ${MEDIA_LIBS}" -LDFLAGS_release="-Os" +LDFLAGS_release="-O2" LDFLAGSEND_asan="" LDFLAGSBEGIN_asan="${ASAN_LIBS} ${MEDIA_LIBS}" LDFLAGSEND_debug="" diff --git a/src/index.cc b/src/index.cc index c0eacbf..b6efbd1 100644 --- a/src/index.cc +++ b/src/index.cc @@ -184,6 +184,10 @@ RC Index::loadIndex(vector &v, break; } // Remove the newline at the end. + if (tar_file.length() == 0) { + failure(INDEX, "File format error gz file. [%d]\n", __LINE__); + break; + } tar_file.pop_back(); if (tar_file.length()==0) continue; auto dots = tar_file.find(" ... ");