summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2020-08-30 09:45:57 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2020-08-30 09:45:57 +0200
commit208ee976f7ec71f8a00ed7dec8a9518d161ce697 (patch)
tree10fea9e66293e43b3db72fe3a187ff5b5017db84
parentc48a93d4c46cde42ab444317794fb7f0f7f31bc4 (diff)
file_7z.c: stricter check
-rw-r--r--src/file_7z.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/file_7z.c b/src/file_7z.c
index bb9675d..583586d 100644
--- a/src/file_7z.c
+++ b/src/file_7z.c
@@ -20,6 +20,7 @@
*/
+#if !defined(SINGLE_FORMAT) || defined(SINGLE_FORMAT_7z)
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -58,6 +59,9 @@ static int header_check_7z(const unsigned char *buffer, const unsigned int buffe
if(buffer_7z->majorversion!=0 ||
le64(buffer_7z->nextHeaderSize)==0)
return 0;
+ if( le64(buffer_7z->nextHeaderOffset) > 0x7000000000000000 ||
+ le64(buffer_7z->nextHeaderSize) > 0x7000000000000000)
+ return 0;
reset_file_recovery(file_recovery_new);
file_recovery_new->extension=file_hint_7z.extension;
file_recovery_new->min_filesize=31;
@@ -74,3 +78,4 @@ static void register_header_check_7z(file_stat_t *file_stat)
static const unsigned char header_7z[6] = {'7','z', 0xbc, 0xaf, 0x27, 0x1c};
register_header_check(0, header_7z, sizeof(header_7z), &header_check_7z, file_stat);
}
+#endif