summaryrefslogtreecommitdiffstats
path: root/src/file_png.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2015-04-11 14:23:16 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2015-04-11 14:23:16 +0200
commit67054372873f2ed5414da7fff1cb5744148289d6 (patch)
treea8cd9501bcfc1e1efec8ca6603e7f11b0ad2ec0c /src/file_png.c
parentefc94ee87ac3b4e3ecf4fb3ab4adac2ef0a6278f (diff)
add gcc_struct attribute to all __packed__ structure
do not use fseeko() with mingw32 gcc compiler
Diffstat (limited to 'src/file_png.c')
-rw-r--r--src/file_png.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/file_png.c b/src/file_png.c
index ae62522..014b1b7 100644
--- a/src/file_png.c
+++ b/src/file_png.c
@@ -38,6 +38,12 @@
#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);
@@ -60,7 +66,7 @@ struct png_chunk
uint32_t type;
char data[0];
/* data is followed by uint32_t crc; */
-} __attribute__ ((__packed__));
+} __attribute__ ((gcc_struct, __packed__));
static int header_check_jng(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)
{
@@ -110,12 +116,7 @@ static void file_check_png(file_recovery_t *fr)
{
char buffer[8];
const struct png_chunk *chunk=(const struct png_chunk *)&buffer;
- if(
-#ifdef HAVE_FSEEKO
- fseeko(fr->handle, fr->file_size, SEEK_SET) < 0 ||
-#else
- fseek(fr->handle, fr->file_size, SEEK_SET) < 0 ||
-#endif
+ if(my_fseek(fr->handle, fr->file_size, SEEK_SET) < 0 ||
fread(&buffer, sizeof(buffer), 1, fr->handle) != 1)
{
fr->file_size=0;