summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2010-12-05 15:57:19 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2010-12-05 15:57:19 +0100
commit9924c4a5972117333055e15b90045af3ab7211ea (patch)
treecf0a3de01674a6c156f51d8e57fc6fd1c2b04301 /src
parentc013ca281dd21ecae068d59870bc9763b3a55787 (diff)
PhotoRec: handle fill bytes before JPG markers
See B.1.1.2 Markers in http://www.w3.org/Graphics/JPEG/itu-t81.pdf
Diffstat (limited to 'src')
-rw-r--r--src/file_jpg.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/file_jpg.c b/src/file_jpg.c
index 80ee331..fafff2b 100644
--- a/src/file_jpg.c
+++ b/src/file_jpg.c
@@ -1059,6 +1059,12 @@ static uint64_t jpg_check_structure(file_recovery_t *file_recovery, const unsign
jpg_search_marker(file_recovery);
return thumb_offset;
}
+ if(buffer[i+1]==0xff)
+ {
+ /* See B.1.1.2 Markers in http://www.w3.org/Graphics/JPEG/itu-t81.pdf*/
+ offset++;
+ continue;
+ }
#ifdef DEBUG_JPEG
log_info("%s marker 0x%02x at 0x%x\n", file_recovery->filename, buffer[i+1], i);
#endif
@@ -1125,6 +1131,12 @@ static uint64_t jpg_check_structure(file_recovery_t *file_recovery, const unsign
jpg_search_marker(file_recovery);
return 0;
}
+ if(buffer[j+1]==0xff)
+ {
+ /* See B.1.1.2 Markers in http://www.w3.org/Graphics/JPEG/itu-t81.pdf*/
+ j++;
+ continue;
+ }
#ifdef DEBUG_JPEG
log_info("%s thumb marker 0x%02x at 0x%x\n", file_recovery->filename, buffer[j+1], j);
#endif
@@ -1377,7 +1389,9 @@ int data_check_jpg(const unsigned char *buffer, const unsigned int buffer_size,
file_recovery->calculated_file_size + 4 < file_recovery->file_size + buffer_size/2)
{
const unsigned int i=file_recovery->calculated_file_size - file_recovery->file_size + buffer_size/2;
- if(buffer[i]==0xFF)
+ if(buffer[i]==0xFF && buffer[i+1]==0xFF)
+ file_recovery->calculated_file_size++;
+ else if(buffer[i]==0xFF)
{
const unsigned int size=(buffer[i+2]<<8)+buffer[i+3];
#if 0