summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--src/askloc.c3
-rw-r--r--src/dir.c4
-rw-r--r--src/fat_unformat.c6
-rw-r--r--src/fidentify.c17
-rw-r--r--src/file_jpg.c15
-rw-r--r--src/file_pdf.c10
-rw-r--r--src/swap.c2
8 files changed, 41 insertions, 18 deletions
diff --git a/configure.ac b/configure.ac
index d81ed0d..acc032f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -783,7 +783,7 @@ case "$target" in
;;
esac
-AC_CHECK_FUNCS([ atexit atoll chdir chmod delscreen dirname dup2 execv fdatasync fsync ftruncate getcwd geteuid getpwuid lstat memalign memchr memset mkdir posix_fadvise posix_memalign pwrite readlink setenv setlocale sigaction signal sleep snprintf strcasecmp strcasestr strchr strdup strerror strncasecmp strptime strrchr strstr strtol strtoul strtoull touchwin uname utime vsnprintf wctomb ])
+AC_CHECK_FUNCS([ atexit atoll chdir chmod delscreen dirname dup2 execv fdatasync fseeko fsync ftello ftruncate getcwd geteuid getpwuid lstat memalign memchr memset mkdir posix_fadvise posix_memalign pwrite readlink setenv setlocale sigaction signal sleep snprintf strcasecmp strcasestr strchr strdup strerror strncasecmp strptime strrchr strstr strtol strtoul strtoull touchwin uname utime vsnprintf wctomb ])
if test "$ac_cv_func_mkdir" = "no"; then
AC_MSG_ERROR(No mkdir function detected)
fi
diff --git a/src/askloc.c b/src/askloc.c
index 49e30fe..3dc41fd 100644
--- a/src/askloc.c
+++ b/src/askloc.c
@@ -169,7 +169,10 @@ char *ask_location(const char*msg, const char *src_dir, const char *dst_org)
WINDOW *window=newwin(LINES, COLS, 0, 0); /* full screen */
aff_copy_short(window);
if(dst_org != NULL)
+ {
strncpy(dst_directory, dst_org, sizeof(dst_directory));
+ dst_directory[sizeof(dst_directory)-1]='\0';
+ }
else
td_getcwd(dst_directory, sizeof(dst_directory));
do
diff --git a/src/dir.c b/src/dir.c
index 318bba9..7f3ba71 100644
--- a/src/dir.c
+++ b/src/dir.c
@@ -642,7 +642,7 @@ char *mkdir_local(const char *localroot, const char *pathname)
unsigned int l;
l=filename_convert(dst_org, src_org, n);
dst=dst_org+l;
- mkdir(localdir, 0775);
+ (void)mkdir(localdir, 0775);
}
#endif
}
@@ -721,7 +721,7 @@ FILE *fopen_local(char **localfilename, const char *localroot, const char *filen
unsigned int l;
l=filename_convert(dst_org, src_org, n);
dst=dst_org+l;
- mkdir(*localfilename, 0775);
+ (void)mkdir(*localfilename, 0775);
}
#endif
}
diff --git a/src/fat_unformat.c b/src/fat_unformat.c
index 73783fe..e15b943 100644
--- a/src/fat_unformat.c
+++ b/src/fat_unformat.c
@@ -102,9 +102,9 @@ static int pfind_sectors_per_cluster(disk_t *disk, partition_t *partition, const
{
const time_t current_time=time(NULL);
if(current_time==previous_time)
- diff_offset>>=1;
- else
diff_offset<<=1;
+ else
+ diff_offset>>=1;
if(diff_offset < disk->sector_size)
diff_offset=disk->sector_size;
next_offset=offset+diff_offset;
@@ -145,7 +145,7 @@ static int fat_copy_file(disk_t *disk, const partition_t *partition, const unsig
#ifdef __MINGW32__
mkdir(new_file);
#else
- mkdir(new_file, 0775);
+ (void)mkdir(new_file, 0775);
#endif
#endif
snprintf(new_file, 1024, "%s.%u/inode_%u/%s", recup_dir, dir_num, inode_num,
diff --git a/src/fidentify.c b/src/fidentify.c
index 3f09d51..3fadf8b 100644
--- a/src/fidentify.c
+++ b/src/fidentify.c
@@ -61,9 +61,9 @@ static int file_identify(const char *filename, const unsigned int check)
unsigned char *buffer_start;
unsigned char *buffer_olddata;
unsigned char *buffer;
- unsigned int blocksize=65536;
+ const unsigned int blocksize=65536;
+ const unsigned int read_size=65536;
unsigned int buffer_size;
- const unsigned int read_size=(blocksize>65536?blocksize:65536);
file_recovery_t file_recovery;
reset_file_recovery(&file_recovery);
file_recovery.blocksize=blocksize;
@@ -114,7 +114,11 @@ static int file_identify(const char *filename, const unsigned int check)
{
file_recovery_new.handle=file;
fseek(file_recovery_new.handle, 0, SEEK_END);
+#ifdef HAVE_FTELLO
+ file_recovery_new.file_size=ftello(file_recovery_new.handle);
+#else
file_recovery_new.file_size=ftell(file_recovery_new.handle);
+#endif
file_recovery_new.calculated_file_size=file_recovery_new.file_size;
(file_recovery_new.file_check)(&file_recovery_new);
printf(" file_size=%llu", (long long unsigned)file_recovery_new.file_size);
@@ -140,13 +144,13 @@ static void file_identify_dir(const char *current_dir, const unsigned int check)
return;
while((entry=readdir(dir))!=NULL)
{
- char current_file[4096];
- strcpy(current_file, current_dir);
- strcat(current_file, "/");
- strcat(current_file, entry->d_name);
if(strcmp(entry->d_name,".")!=0 && strcmp(entry->d_name,"..")!=0)
{
struct stat buf_stat;
+ char *current_file=(char *)MALLOC(strlen(current_dir)+1+strlen(entry->d_name)+1);
+ strcpy(current_file, current_dir);
+ strcat(current_file, "/");
+ strcat(current_file, entry->d_name);
#ifdef HAVE_LSTAT
if(lstat(current_file, &buf_stat)==0)
#else
@@ -158,6 +162,7 @@ static void file_identify_dir(const char *current_dir, const unsigned int check)
else if(S_ISREG(buf_stat.st_mode))
file_identify(current_file, check);
}
+ free(current_file);
}
}
closedir(dir);
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)
diff --git a/src/file_pdf.c b/src/file_pdf.c
index 58c6136..c4a61af 100644
--- a/src/file_pdf.c
+++ b/src/file_pdf.c
@@ -77,7 +77,7 @@ static void file_rename_pdf(const char *old_filename)
{
char title[512];
const unsigned char pattern[6]={ '/', 'T', 'i', 't', 'l', 'e' };
- uint64_t offset;
+ off_t offset;
FILE *handle;
unsigned char*buffer;
unsigned int i;
@@ -91,7 +91,11 @@ static void file_rename_pdf(const char *old_filename)
fclose(handle);
return;
}
+#ifdef HAVE_FTELLO
+ offset=ftello(handle);
+#else
offset=ftell(handle);
+#endif
if(offset < 0)
{
fclose(handle);
@@ -104,7 +108,11 @@ static void file_rename_pdf(const char *old_filename)
return;
}
offset+=sizeof(pattern);
+#ifdef HAVE_FSEEKO
+ if(fseeko(handle, offset, SEEK_SET)<0)
+#else
if(fseek(handle, offset, SEEK_SET)<0)
+#endif
{
fclose(handle);
return ;
diff --git a/src/swap.c b/src/swap.c
index 3205eec..5a5494b 100644
--- a/src/swap.c
+++ b/src/swap.c
@@ -142,7 +142,7 @@ int recover_Linux_SWAP(const union swap_header *swap_header, partition_t *partit
for(j=7;j>=0;j--)
if((swap_header->magic.reserved[i]&(1<<j))!=(char)0)
break;
- partition->part_size=(uint64_t)((8*i+j+1)*PAGE_SIZE);
+ partition->part_size=(uint64_t)(8*i+j+1)*PAGE_SIZE;
}
break;
case UP_LINSWAP2: