From 7a6a7f54d1f27c6b3520fe8cffebeebc6c272ca0 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 29 Oct 2020 21:22:05 +0100 Subject: fix #6613 --- ChangeLog | 9 ++++++-- src/plugins/fuzz_default.sh | 17 ++++++++++++--- src/plugins/test_exiv2.c | 14 +++++++------ src/plugins/test_lib.c | 50 +++++++++++++++++++++++++++++++++++++-------- src/plugins/test_lib.h | 5 +++++ 5 files changed, 75 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 49821b0..afbcecc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,11 @@ +Thu Oct 29 09:20:41 PM CET 2020 + Fix #6613: test failure with latest exiv2 library + (harmless). Add hard timeout for zzuf test suite + on systems where timeout command exists. -CG + Thu Jul 2 15:58:16 CEST 2020 - Fixed some code that called deprecated libav routines. - Improved configure reporting. + Fixed some code that called deprecated libav routines. + Improved configure reporting. Releasing GNU libextractor 1.10. -CG Tue 02 Jun 2020 11:14:43 PM CEST diff --git a/src/plugins/fuzz_default.sh b/src/plugins/fuzz_default.sh index 8b64539..67292cf 100755 --- a/src/plugins/fuzz_default.sh +++ b/src/plugins/fuzz_default.sh @@ -14,6 +14,17 @@ then bindir="$bindir/bin" fi +if test -x `which zzuf` +then + exit 77 +fi + +if test -x `which timeout` +then + TIMEOUT=timeout 15 +else + TIMEOUT="" +fi for file in $testdatadir/test* do @@ -26,11 +37,11 @@ do do echo "file $file seed $seed" zzuf -c -s $seed cat "$file" > "$tmpfile" - if ! "$bindir/extract" -i "$tmpfile" > /dev/null + if ! "$TIMEOUT $bindir/extract" -i "$tmpfile" > /dev/null then echo "$tmpfile with seed $seed failed" - mv $tmpfile $tmpfile.keep - ret=1 + mv $tmpfile $tmpfile.keep + ret=1 fi seed=`expr $seed + 1` done diff --git a/src/plugins/test_exiv2.c b/src/plugins/test_exiv2.c index e4e5319..f3dae0a 100644 --- a/src/plugins/test_exiv2.c +++ b/src/plugins/test_exiv2.c @@ -49,9 +49,10 @@ main (int argc, char *argv[]) EXTRACTOR_METATYPE_GPS_LATITUDE, EXTRACTOR_METAFORMAT_UTF8, "text/plain", - "28deg 8' 17.585\" ", - strlen ("28deg 8' 17.585\" ") + 1, - 0 + "28deg 8' (18|17.585)\" ?", + strlen ("28deg 8' (18|17.585)\" ?") + 1, + 0, + .regex = 1 }, { EXTRACTOR_METATYPE_GPS_LONGITUDE_REF, @@ -65,9 +66,10 @@ main (int argc, char *argv[]) EXTRACTOR_METATYPE_GPS_LONGITUDE, EXTRACTOR_METAFORMAT_UTF8, "text/plain", - "14deg 14' 21.713\" ", - strlen ("14deg 14' 21.713\" ") + 1, - 0 + "14deg 14' (22|21.713)\" ?", + strlen ("14deg 14' (22|21.713)\" ?"), + 0, + .regex = 1 }, { EXTRACTOR_METATYPE_CAMERA_MAKE, diff --git a/src/plugins/test_lib.c b/src/plugins/test_lib.c index efbe2cf..97d4dc5 100644 --- a/src/plugins/test_lib.c +++ b/src/plugins/test_lib.c @@ -24,7 +24,8 @@ */ #include "platform.h" #include "test_lib.h" - +#include +#include /** * Function that libextractor calls for each @@ -57,14 +58,45 @@ process_replies (void *cls, (sd[i].type != type) || (sd[i].format != format) ) continue; - if ( (EXTRACTOR_METAFORMAT_BINARY != format) && - ( (sd[i].data_len != data_len) || - (0 != memcmp (sd[i].data, data, data_len)) ) ) - continue; - if ( (EXTRACTOR_METAFORMAT_BINARY == format) && - ( (sd[i].data_len > data_len) || - (0 != memcmp (sd[i].data, data, sd[i].data_len)) ) ) - continue; + if ( (sd[i].regex) && + (EXTRACTOR_METAFORMAT_BINARY != format) ) + { + regex_t re; + regmatch_t match; + + if (0 != + regcomp (&re, + sd[i].data, + REG_EXTENDED)) + { + fprintf (stderr, + "Not a valid regex: %s\n", + sd[i].data); + abort (); + } + if ( ('\0' != data[data_len - 1]) || + (0 != regexec (&re, + data, + 1, + &match, + 0)) ) + { + regfree (&re); + continue; + } + regfree (&re); + } + else + { + if ( (EXTRACTOR_METAFORMAT_BINARY != format) && + ( (sd[i].data_len != data_len) || + (0 != memcmp (sd[i].data, data, data_len)) ) ) + continue; + if ( (EXTRACTOR_METAFORMAT_BINARY == format) && + ( (sd[i].data_len > data_len) || + (0 != memcmp (sd[i].data, data, sd[i].data_len)) ) ) + continue; + } if (NULL != sd[i].data_mime_type) { diff --git a/src/plugins/test_lib.h b/src/plugins/test_lib.h index 9400314..cea36fc 100644 --- a/src/plugins/test_lib.h +++ b/src/plugins/test_lib.h @@ -63,6 +63,11 @@ struct SolutionData * terminate the list. */ int solved; + + /** + * Treat solution as a regex that must match. + */ + int regex; }; -- cgit v1.2.3