summaryrefslogtreecommitdiffstats
path: root/src/file_jpg.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2013-11-03 15:24:33 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2013-11-03 15:24:33 +0100
commit191a261516d0f55336f37ced9fa3695d66d225d9 (patch)
tree1c74a906a1da183586adba291a2dd56cb9f3f16c /src/file_jpg.c
parent2fd70a3b9ed309f1cf3f57d10faebf29bb451037 (diff)
fix minor code defects
Diffstat (limited to 'src/file_jpg.c')
-rw-r--r--src/file_jpg.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/file_jpg.c b/src/file_jpg.c
index 5ea2d8f..4c1a6b6 100644
--- a/src/file_jpg.c
+++ b/src/file_jpg.c
@@ -219,7 +219,11 @@ static void file_check_mpo(file_recovery_t *fr)
do
{
offset+=2+size;
- fseek(fr->handle, offset, SEEK_SET);
+ if(fseek(fr->handle, offset, SEEK_SET) < 0)
+ {
+ fr->file_size=0;
+ return ;
+ }
nbytes=fread(&buffer, 1, sizeof(buffer), fr->handle);
// log_info("file_check_mpo offset=%llu => nbytes=%d, buffer=%02x %02x\n",
// (long long unsigned)offset, nbytes, buffer[0], buffer[1]);
@@ -707,8 +711,11 @@ static inline void jpeg_session_suspend(struct jpeg_session_struct *jpeg_session
static void jpeg_session_start(struct jpeg_session_struct *jpeg_session)
{
- fseek(jpeg_session->handle, jpeg_session->offset, SEEK_SET);
- jpeg_create_decompress(&jpeg_session->cinfo);
+ if(fseek(jpeg_session->handle, jpeg_session->offset, SEEK_SET) < 0)
+ {
+ log_critical("jpeg_session_start: fseek failed.\n");
+ }
+ jpeg_create_decompress(&jpeg_session->cinfo);
jpeg_testdisk_src(&jpeg_session->cinfo, jpeg_session->handle, jpeg_session->offset, jpeg_session->blocksize);
(void) jpeg_read_header(&jpeg_session->cinfo, TRUE);
jpeg_session->cinfo.two_pass_quantize = FALSE;
@@ -1416,7 +1423,7 @@ static uint64_t jpg_check_structure(file_recovery_t *file_recovery, const unsign
#ifdef DEBUG_JPEG
j_old=j;
#endif
- j+=2+(buffer[j+2]<<8)+buffer[j+3];
+ j+=2U+(buffer[j+2]<<8)+buffer[j+3];
}
if(thumb_sos_found>0 && extract_thumb>0
&& offset < nbytes && buffer[offset]==0xff)