summaryrefslogtreecommitdiffstats
path: root/src/file_exe.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2009-03-15 21:20:21 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2009-03-15 21:20:21 +0100
commitaaaac59018959315a236e8c1cda3f21964c99550 (patch)
tree90cd1078b0ece5f03ca2c89e730ed15fca49016c /src/file_exe.c
parent1f117235459041ce9d22988a982185edafc49c9b (diff)
PhotoRec: limit recursion depth and loop count when checking exe information
Diffstat (limited to 'src/file_exe.c')
-rw-r--r--src/file_exe.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/file_exe.c b/src/file_exe.c
index d87e92a..0a7a078 100644
--- a/src/file_exe.c
+++ b/src/file_exe.c
@@ -241,7 +241,7 @@ static void PEVersion(FILE *file, const unsigned int offset, const unsigned int
char *buffer;
unsigned int pos=0;
unsigned int end=length;
- if(length==0)
+ if(length==0 || length > 1024*1024)
return;
if(fseek(file, offset, SEEK_SET)<0)
return ;
@@ -340,7 +340,7 @@ static void file_exe_ressource(FILE *file, const unsigned int base, const unsign
#ifdef DEBUG_EXE
log_info("file_exe_ressource(file, %u, %u, %u, %u)\n", base, dir_start, size, level);
#endif
- if(level >= 10)
+ if(level > 2)
return ;
if(fseek(file, base + dir_start, SEEK_SET)<0)
return ;
@@ -350,7 +350,7 @@ static void file_exe_ressource(FILE *file, const unsigned int base, const unsign
nameEntries = buffer[12]+(buffer[13]<<8);
idEntries = buffer[14]+(buffer[15]<<8);
count = nameEntries + idEntries;
- if(count==0)
+ if(count==0 || count > 1024)
return ;
rsrc_entries=(struct rsrc_entries *)MALLOC(count * sizeof(struct rsrc_entries));
if(fread(rsrc_entries, sizeof(struct rsrc_entries), count, file) != count)