PhotoRec: check fseek return value in jpg file validation

This commit is contained in:
Christophe Grenier 2011-10-15 12:09:28 +02:00
parent 7e5749b013
commit fc97dd06e0

View file

@ -527,7 +527,8 @@ static inline int jpeg_session_resume(struct jpeg_session_struct *jpeg_session)
if(resume_memory((j_common_ptr)&jpeg_session->cinfo)) if(resume_memory((j_common_ptr)&jpeg_session->cinfo))
return -1; return -1;
src = (my_source_mgr *) jpeg_session->cinfo.src; src = (my_source_mgr *) jpeg_session->cinfo.src;
fseek(jpeg_session->handle, jpeg_session->offset + src->file_size, SEEK_SET); if(fseek(jpeg_session->handle, jpeg_session->offset + src->file_size, SEEK_SET) < 0)
return -1;
return 0; return 0;
} }
@ -1061,7 +1062,8 @@ static void jpg_search_marker(file_recovery_t *file_recovery)
return ; return ;
offset=file_recovery->offset_error / file_recovery->blocksize * file_recovery->blocksize; offset=file_recovery->offset_error / file_recovery->blocksize * file_recovery->blocksize;
i=file_recovery->offset_error % file_recovery->blocksize; i=file_recovery->offset_error % file_recovery->blocksize;
fseek(infile, offset, SEEK_SET); if(fseek(infile, offset, SEEK_SET) < 0)
return ;
do do
{ {
while((nbytes=fread(&buffer, 1, sizeof(buffer), infile))>0) while((nbytes=fread(&buffer, 1, sizeof(buffer), infile))>0)
@ -1102,7 +1104,8 @@ static uint64_t jpg_check_structure(file_recovery_t *file_recovery, const unsign
uint64_t thumb_offset=0; uint64_t thumb_offset=0;
int nbytes; int nbytes;
file_recovery->extra=0; file_recovery->extra=0;
fseek(infile, 0, SEEK_SET); if(fseek(infile, 0, SEEK_SET) < 0)
return 0;
if((nbytes=fread(&buffer, 1, sizeof(buffer), infile))>0) if((nbytes=fread(&buffer, 1, sizeof(buffer), infile))>0)
{ {
unsigned int offset; unsigned int offset;