PhotoRec: avoid to truncate the file too short when there isn't enough data to read
This commit is contained in:
parent
6d955e1fa5
commit
f6545386c0
1 changed files with 4 additions and 2 deletions
|
@ -873,7 +873,9 @@ static void jpg_check_picture(file_recovery_t *file_recovery)
|
||||||
*/
|
*/
|
||||||
my_source_mgr * src;
|
my_source_mgr * src;
|
||||||
src = (my_source_mgr *) jpeg_session.cinfo.src;
|
src = (my_source_mgr *) jpeg_session.cinfo.src;
|
||||||
jpeg_size=src->file_size - src->pub.bytes_in_buffer;
|
jpeg_size=src->file_size;
|
||||||
|
if(src->pub.bytes_in_buffer >= 4)
|
||||||
|
jpeg_size-=src->pub.bytes_in_buffer;
|
||||||
if(jpeg_size>0)
|
if(jpeg_size>0)
|
||||||
file_recovery->offset_error=jpeg_size;
|
file_recovery->offset_error=jpeg_size;
|
||||||
if(file_recovery->offset_ok < src->offset_ok)
|
if(file_recovery->offset_ok < src->offset_ok)
|
||||||
|
@ -1267,7 +1269,7 @@ static void file_check_jpg(file_recovery_t *file_recovery)
|
||||||
if(file_recovery->offset_error==0 || file_recovery->offset_error > thumb_error)
|
if(file_recovery->offset_error==0 || file_recovery->offset_error > thumb_error)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_JPEG
|
#ifdef DEBUG_JPEG
|
||||||
log_info("Thumb usefull, error at %llu\n", thumb_error);
|
log_info("Thumb usefull, error at %llu\n", (long long unsigned)thumb_error);
|
||||||
#endif
|
#endif
|
||||||
file_recovery->offset_error = thumb_error;
|
file_recovery->offset_error = thumb_error;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue