summaryrefslogtreecommitdiffstats
path: root/src/file_riff.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2011-09-23 20:12:07 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2011-09-23 20:12:07 +0200
commite014a0c410ea127b70f51b56a8116357ac247faf (patch)
tree2268fce25f89f83518739d93fc69d6049abd08d7 /src/file_riff.c
parentdbd3e4a8e091d84cf9b0b2c4a8265830e20e7b98 (diff)
PhotoRec: fix RIFF filesize detection
Diffstat (limited to 'src/file_riff.c')
-rw-r--r--src/file_riff.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/file_riff.c b/src/file_riff.c
index c3d3e74..ccb2c61 100644
--- a/src/file_riff.c
+++ b/src/file_riff.c
@@ -113,7 +113,11 @@ static void check_riff_list(file_recovery_t *fr, const unsigned int depth, const
return;
for(file_size=start; file_size < end;)
{
- fseek(fr->handle, file_size, SEEK_SET);
+ if(fseek(fr->handle, file_size, SEEK_SET)<0)
+ {
+ fr->offset_error=file_size;
+ return;
+ }
if (fread(&list_header, sizeof(list_header), 1, fr->handle)!=1)
{
fr->offset_error=file_size;
@@ -148,9 +152,16 @@ static void file_check_avi(file_recovery_t *fr)
{
const uint64_t file_size=fr->file_size;
riff_list_header list_header;
- fseek(fr->handle, fr->file_size, SEEK_SET);
+ if(fseek(fr->handle, fr->file_size, SEEK_SET)<0)
+ {
+ fr->file_size=0;
+ return ;
+ }
if (fread(&list_header, sizeof(list_header), 1, fr->handle)!=1)
+ {
+ fr->file_size=0;
return;
+ }
#ifdef DEBUG_RIFF
log_riff_list(file_size, 0, &list_header);
#endif
@@ -162,7 +173,10 @@ static void file_check_avi(file_recovery_t *fr)
}
check_riff_list(fr, 1, file_size + sizeof(list_header), file_size + 8 + le32(list_header.dwSize) - 1);
if(fr->offset_error > 0)
+ {
+ fr->file_size=0;
return;
+ }
fr->file_size=file_size + 8 + le32(list_header.dwSize);
}
}