PhotoRec: check fseek return value in nk2 file validation

This commit is contained in:
Christophe Grenier 2011-10-15 12:09:41 +02:00
parent fc97dd06e0
commit 23ca9115bd

View file

@ -109,16 +109,12 @@ static void file_check_nk2(file_recovery_t *fr)
{
nk2Header nk2h;
unsigned int i;
fseek(fr->handle, 0, SEEK_SET);
fr->file_size = 0;
fr->offset_error=0;
fr->offset_ok=0;
if (fread(&nk2h, sizeof(nk2h), 1, fr->handle)!=1)
{
fr->offset_error=fr->file_size;
fr->file_size=0;
if(fseek(fr->handle, 0, SEEK_SET) < 0 ||
fread(&nk2h, sizeof(nk2h), 1, fr->handle)!=1)
return;
}
fr->file_size+=sizeof(nk2h);
#ifdef DEBUG_NK2
log_info("nk2 item_count=%u\n", (unsigned int)le32(nk2h.items_count));