summaryrefslogtreecommitdiffstats
path: root/src/file_mig.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2013-03-10 16:02:12 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2013-03-10 16:02:12 +0100
commit54a8eadd5c3e6fb6114b4e3de99fc6f7f5ab48d1 (patch)
tree62e8840edc224ea9fe75d3577e34ae6c74b9dbce /src/file_mig.c
parent85c3ba54adb022f1dd6198060d41ffbbedde19fd (diff)
PhotoRec: fix .mig recovery when blocksize=1
Diffstat (limited to 'src/file_mig.c')
-rw-r--r--src/file_mig.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/file_mig.c b/src/file_mig.c
index 9e00288..01c155d 100644
--- a/src/file_mig.c
+++ b/src/file_mig.c
@@ -64,15 +64,23 @@ static void file_check_mig(file_recovery_t *file_recovery)
file_recovery->file_size=0;
while(1)
{
- if(fseek(file_recovery->handle, offset, SEEK_SET) < 0 ||
- fread(&h, sizeof(h), 1, file_recovery->handle) != 1)
+ size_t res;
+ if(fseek(file_recovery->handle, offset, SEEK_SET) < 0)
{
#ifdef DEBUG_MIG
- log_info("0x%lx no header\n", (long unsigned)offset);
+ log_info("0x%lx fseek failed\n", (long unsigned)offset);
#endif
return ;
}
- if(le32(h.magic)!=0x5354524d) /* STRM=stream */
+ res=fread(&h, 1, sizeof(h), file_recovery->handle);
+ if(res < 8)
+ {
+#ifdef DEBUG_MIG
+ log_info("0x%lx not enough data\n", (long unsigned)offset);
+#endif
+ return ;
+ }
+ if(res < sizeof(h) || le32(h.magic)!=0x5354524d) /* STRM=stream */
{
#ifdef DEBUG_MIG
log_info("0x%lx no magic %x\n", (long unsigned)offset, le32(h.magic));