summaryrefslogtreecommitdiffstats
path: root/src/file_pzh.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2011-10-15 12:10:01 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2011-10-15 12:10:01 +0200
commit0053652d699ac60dfd14afb0ea409e524783e90a (patch)
tree2f0e0d27f2123ca9c092d1b61d4193a424b63c66 /src/file_pzh.c
parent21ec1345e9fce364a1c883ab933407428029f98c (diff)
PhotoRec: check fseek return value in pzh file validation
Diffstat (limited to 'src/file_pzh.c')
-rw-r--r--src/file_pzh.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/file_pzh.c b/src/file_pzh.c
index bda0065..7c6f5b7 100644
--- a/src/file_pzh.c
+++ b/src/file_pzh.c
@@ -62,10 +62,15 @@ static void file_rename_pzh(const char *old_filename)
int buffer_size;
if((file=fopen(old_filename, "rb"))==NULL)
return;
- fseek(file, 0x9ce, SEEK_SET);
+ if(fseek(file, 0x9ce, SEEK_SET)<0)
+ {
+ fclose(file);
+ return ;
+ }
buffer_size=fread(buffer, 1, sizeof(buffer), file);
fclose(file);
- file_rename(old_filename, buffer, buffer_size, 0, "pzh", 0);
+ if(buffer_size > 0)
+ file_rename(old_filename, buffer, buffer_size, 0, "pzh", 0);
}
static int header_check_pzh(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)