summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2012-10-21 12:14:25 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2012-10-21 12:14:25 +0200
commitac415fbfee7f92cebc85538f63843d8974254aef (patch)
treedcac79305d8ec46e9bfd2cb71c5297fa9a3f05ce /src
parentea7966cef9f1d72860ee68e01b9f3ebf7fa33dc9 (diff)
PhotoRec: fix recovered .hdf file
Diffstat (limited to 'src')
-rw-r--r--src/file_hdf.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/file_hdf.c b/src/file_hdf.c
index d574ab7..79359ad 100644
--- a/src/file_hdf.c
+++ b/src/file_hdf.c
@@ -95,13 +95,15 @@ static void file_check_hdf(file_recovery_t *file_recovery)
log_info("tag=0x%04x, ref=%u, offset=%lu, length=%lu\n",
be16(p->tag), be16(p->ref), be32(p->offset), be32(p->length));
#endif
- if(file_size < be32(p->offset) + be32(p->length))
- file_size = be32(p->offset) + be32(p->length);
+ if((unsigned)be32(p->offset)!=(unsigned)(-1) &&
+ file_size < (unsigned)be32(p->offset) + (unsigned)be32(p->length))
+ file_size = (unsigned)be32(p->offset) + (unsigned)be32(p->length);
}
offset_old=offset;
offset=be32(ddh.next);
} while(offset > offset_old);
free(dd);
+ file_size++;
#ifdef DEBUG_HDF
log_info("file_size %llu\n", (long long unsigned)file_size);
#endif