summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2015-09-25 20:32:08 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2015-09-25 20:32:08 +0200
commit5d18a4828bc74677ec17db07a4d8de2cc75be032 (patch)
treec4b10474ddd5eca6447f8fe4a541f7b0c35f961e
parent21827baef53aaa4a8c97f35850722b93c42f5914 (diff)
Fallback to fseek() if fseeko() failed
-rw-r--r--src/fidentify.c5
-rw-r--r--src/file_ace.c5
-rw-r--r--src/file_axx.c5
-rw-r--r--src/file_doc.c6
-rw-r--r--src/file_dv.c6
-rw-r--r--src/file_gif.c6
-rw-r--r--src/file_gpg.c6
-rw-r--r--src/file_hdf.c6
-rw-r--r--src/file_indd.c6
-rw-r--r--src/file_jpg.c6
-rw-r--r--src/file_m2ts.c6
-rw-r--r--src/file_mid.c6
-rw-r--r--src/file_mig.c6
-rw-r--r--src/file_mlv.c6
-rw-r--r--src/file_nk2.c6
-rw-r--r--src/file_par2.c6
-rw-r--r--src/file_pdf.c6
-rw-r--r--src/file_png.c6
-rw-r--r--src/file_riff.c6
-rw-r--r--src/file_spf.c6
-rw-r--r--src/file_tib.c6
-rw-r--r--src/file_zip.c6
-rw-r--r--src/filegen.c18
-rw-r--r--src/filegen.h1
-rw-r--r--src/phbf.c6
-rw-r--r--src/photorec.c6
26 files changed, 13 insertions, 147 deletions
diff --git a/src/fidentify.c b/src/fidentify.c
index 2a07334..617e7a3 100644
--- a/src/fidentify.c
+++ b/src/fidentify.c
@@ -56,11 +56,6 @@ extern file_enable_t list_file_enable[];
extern file_check_list_t file_check_list;
#define READ_SIZE 1024*512
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
static int file_identify(const char *filename, const unsigned int check)
{
diff --git a/src/file_ace.c b/src/file_ace.c
index 737c7e2..360c56e 100644
--- a/src/file_ace.c
+++ b/src/file_ace.c
@@ -34,11 +34,6 @@
#include "crc.h"
/* #define DEBUG_ACE */
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
static void register_header_check_ace(file_stat_t *file_stat);
diff --git a/src/file_axx.c b/src/file_axx.c
index a1277af..bc6bc4a 100644
--- a/src/file_axx.c
+++ b/src/file_axx.c
@@ -48,11 +48,6 @@ struct SHeader
uint32_t aoLength;
uint8_t oType;
} __attribute__ ((gcc_struct, __packed__));
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
static void file_check_axx(file_recovery_t *fr)
{
diff --git a/src/file_doc.c b/src/file_doc.c
index c3d5ffa..22f1a6a 100644
--- a/src/file_doc.c
+++ b/src/file_doc.c
@@ -38,12 +38,6 @@
#include "memmem.h"
#include "setdate.h"
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
-
static void register_header_check_doc(file_stat_t *file_stat);
static void file_check_doc(file_recovery_t *file_recovery);
static int header_check_doc(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new);
diff --git a/src/file_dv.c b/src/file_dv.c
index e44b859..6aabd81 100644
--- a/src/file_dv.c
+++ b/src/file_dv.c
@@ -41,12 +41,6 @@ const file_hint_t file_hint_dv= {
.register_header_check=&register_header_check_dv
};
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
-
static data_check_t data_check_NTSC(const unsigned char *buffer, const unsigned int buffer_size, file_recovery_t *file_recovery)
{
while(file_recovery->calculated_file_size + buffer_size/2 >= file_recovery->file_size &&
diff --git a/src/file_gif.c b/src/file_gif.c
index d14e05a..6f093c5 100644
--- a/src/file_gif.c
+++ b/src/file_gif.c
@@ -31,12 +31,6 @@
#include "filegen.h"
#include "log.h"
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
-
static void register_header_check_gif(file_stat_t *file_stat);
static int header_check_gif(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new);
static void file_check_gif(file_recovery_t *file_recovery);
diff --git a/src/file_gpg.c b/src/file_gpg.c
index 12c6386..b1aadf0 100644
--- a/src/file_gpg.c
+++ b/src/file_gpg.c
@@ -34,12 +34,6 @@
#include "log.h"
#endif
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
-
static void register_header_check_gpg(file_stat_t *file_stat);
static int header_check_gpg(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new);
diff --git a/src/file_hdf.c b/src/file_hdf.c
index 5c64e43..0eec179 100644
--- a/src/file_hdf.c
+++ b/src/file_hdf.c
@@ -37,12 +37,6 @@
#include "log.h"
#endif
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
-
static void register_header_check_hdf(file_stat_t *file_stat);
const file_hint_t file_hint_hdf= {
diff --git a/src/file_indd.c b/src/file_indd.c
index 22b71df..4b6bb2c 100644
--- a/src/file_indd.c
+++ b/src/file_indd.c
@@ -33,12 +33,6 @@
#include "filegen.h"
#include "log.h"
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
-
static void register_header_check_indd(file_stat_t *file_stat);
static int header_check_indd(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new);
static void file_check_indd(file_recovery_t *file_recovery);
diff --git a/src/file_jpg.c b/src/file_jpg.c
index 45d95cb..4665836 100644
--- a/src/file_jpg.c
+++ b/src/file_jpg.c
@@ -50,12 +50,6 @@
#include "file_tiff.h"
#include "setdate.h"
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
-
extern const file_hint_t file_hint_doc;
extern const file_hint_t file_hint_indd;
extern const file_hint_t file_hint_mov;
diff --git a/src/file_m2ts.c b/src/file_m2ts.c
index bc50fa8..1eda27a 100644
--- a/src/file_m2ts.c
+++ b/src/file_m2ts.c
@@ -30,12 +30,6 @@
#include "types.h"
#include "filegen.h"
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
-
static void register_header_check_m2ts(file_stat_t *file_stat);
static void register_header_check_ts(file_stat_t *file_stat);
diff --git a/src/file_mid.c b/src/file_mid.c
index 3fb0703..06d82de 100644
--- a/src/file_mid.c
+++ b/src/file_mid.c
@@ -32,12 +32,6 @@
#include "common.h"
#include "log.h"
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
-
static void register_header_check_mid(file_stat_t *file_stat);
const file_hint_t file_hint_mid= {
diff --git a/src/file_mig.c b/src/file_mig.c
index 93d807a..b60a8b9 100644
--- a/src/file_mig.c
+++ b/src/file_mig.c
@@ -34,12 +34,6 @@
#include "log.h"
#endif
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
-
static void register_header_check_mig(file_stat_t *file_stat);
const file_hint_t file_hint_mig= {
diff --git a/src/file_mlv.c b/src/file_mlv.c
index 38cb55b..716fc24 100644
--- a/src/file_mlv.c
+++ b/src/file_mlv.c
@@ -31,12 +31,6 @@
#include "filegen.h"
#include "common.h"
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
-
static void register_header_check_mlv(file_stat_t *file_stat);
const file_hint_t file_hint_mlv= {
diff --git a/src/file_nk2.c b/src/file_nk2.c
index 64f6052..4e2a44a 100644
--- a/src/file_nk2.c
+++ b/src/file_nk2.c
@@ -32,12 +32,6 @@
#include "common.h"
#include "log.h"
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
-
static void register_header_check_nk2(file_stat_t *file_stat);
const file_hint_t file_hint_nk2= {
diff --git a/src/file_par2.c b/src/file_par2.c
index 68628b7..0af6954 100644
--- a/src/file_par2.c
+++ b/src/file_par2.c
@@ -32,12 +32,6 @@
#include "common.h"
#include "log.h"
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
-
static void register_header_check_par2(file_stat_t *file_stat);
const file_hint_t file_hint_par2= {
diff --git a/src/file_pdf.c b/src/file_pdf.c
index 1a3d8f6..9be41c3 100644
--- a/src/file_pdf.c
+++ b/src/file_pdf.c
@@ -39,12 +39,6 @@
#include "memmem.h"
#include "common.h"
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
-
static void register_header_check_pdf(file_stat_t *file_stat);
static void file_date_pdf(file_recovery_t *file_recovery);
diff --git a/src/file_png.c b/src/file_png.c
index d61ae1f..4cd2094 100644
--- a/src/file_png.c
+++ b/src/file_png.c
@@ -38,12 +38,6 @@
#include "common.h"
#include "filegen.h"
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
-
extern const file_hint_t file_hint_doc;
static void register_header_check_png(file_stat_t *file_stat);
diff --git a/src/file_riff.c b/src/file_riff.c
index e54ca52..3ecfc61 100644
--- a/src/file_riff.c
+++ b/src/file_riff.c
@@ -34,12 +34,6 @@
#include "log.h"
#endif
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
-
data_check_t data_check_avi_stream(const unsigned char *buffer, const unsigned int buffer_size, file_recovery_t *file_recovery);
static void register_header_check_riff(file_stat_t *file_stat);
diff --git a/src/file_spf.c b/src/file_spf.c
index bda990f..65b239f 100644
--- a/src/file_spf.c
+++ b/src/file_spf.c
@@ -32,12 +32,6 @@
#include "filegen.h"
#include "common.h"
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
-
static void register_header_check_spf(file_stat_t *file_stat);
const file_hint_t file_hint_spf= {
diff --git a/src/file_tib.c b/src/file_tib.c
index d8508fb..0fc9ab5 100644
--- a/src/file_tib.c
+++ b/src/file_tib.c
@@ -34,12 +34,6 @@
#include "filegen.h"
#include "common.h"
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
-
static void register_header_check_tib(file_stat_t *file_stat);
static int header_check_tib(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new);
diff --git a/src/file_zip.c b/src/file_zip.c
index fbf3b4f..c250c6f 100644
--- a/src/file_zip.c
+++ b/src/file_zip.c
@@ -42,12 +42,6 @@
/* #define DEBUG_ZIP */
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
-
extern const file_hint_t file_hint_doc;
static void register_header_check_zip(file_stat_t *file_stat);
static int header_check_zip(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new);
diff --git a/src/filegen.c b/src/filegen.c
index d80097c..ffde54f 100644
--- a/src/filegen.c
+++ b/src/filegen.c
@@ -37,12 +37,6 @@
#include "photorec.h"
#include "log.h"
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
-
static file_check_t file_check_plist={
.list = TD_LIST_HEAD_INIT(file_check_plist.list)
};
@@ -626,3 +620,15 @@ void get_prev_location_smart(alloc_data_t *list_search_space, alloc_data_t **cur
}
offset_skipped_header=0;
}
+
+int my_fseek(FILE *stream, off_t offset, int whence)
+{
+#if defined(HAVE_FSEEKO) && !defined(__MINGW32__) && !defined(__ARM_EABI__)
+ {
+ int res;
+ if((res=fseeko(stream, offset, whence))>=0)
+ return res;
+ }
+#endif
+ return fseek(stream, offset, whence);
+}
diff --git a/src/filegen.h b/src/filegen.h
index 97b3426..2ab5e64 100644
--- a/src/filegen.h
+++ b/src/filegen.h
@@ -135,6 +135,7 @@ file_stat_t * init_file_stats(file_enable_t *files_enable);
int file_rename(file_recovery_t *file_recovery, const void *buffer, const int buffer_size, const int offset, const char *new_ext, const int force_ext);
int file_rename_unicode(file_recovery_t *file_recovery, const void *buffer, const int buffer_size, const int offset, const char *new_ext, const int force_ext);
void header_ignored(const file_recovery_t *file_recovery_new);
+int my_fseek(FILE *stream, off_t offset, int whence);
#ifdef __cplusplus
} /* closing brace for extern "C" */
diff --git a/src/phbf.c b/src/phbf.c
index d00bc3c..68fc310 100644
--- a/src/phbf.c
+++ b/src/phbf.c
@@ -71,12 +71,6 @@
#include "phbf.h"
#include "phnc.h"
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
-
//#define DEBUG_BF
//#define DEBUG_BF2
#define READ_SIZE 1024*512
diff --git a/src/photorec.c b/src/photorec.c
index 3851f56..b05a3e8 100644
--- a/src/photorec.c
+++ b/src/photorec.c
@@ -55,12 +55,6 @@
#include "setdate.h"
#include "dfxml.h"
-#if defined(HAVE_FSEEKO) && !defined(__MINGW32__)
-#define my_fseek fseeko
-#else
-#define my_fseek fseek
-#endif
-
/* #define DEBUG_FILE_FINISH */
/* #define DEBUG_UPDATE_SEARCH_SPACE */
/* #define DEBUG_FREE */