summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Bolte <sbolte@lavabit.com>2013-05-15 15:55:18 +0200
committerStefan Bolte <sbolte@lavabit.com>2013-05-15 15:55:18 +0200
commitd4596cb45882959e8a4c292db6955550525f0c54 (patch)
treed37500966900136ce40adfd699395e5463b5370b
parent513127d3a295b6fd96227338815956598386c60c (diff)
downloaddwb-d4596cb45882959e8a4c292db6955550525f0c54.zip
Checking file type of exar files
-rw-r--r--tools/exar/exar.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/tools/exar/exar.c b/tools/exar/exar.c
index 06714f9e..44525400 100644
--- a/tools/exar/exar.c
+++ b/tools/exar/exar.c
@@ -24,26 +24,30 @@
#include <unistd.h>
#include <ftw.h>
#include "exar.h"
-#define VERSION "exar-1"
+
+#define VERSION_BASE "exar-"
+#define VERSION VERSION_BASE "1"
#define EXTENSION "exar"
#define SZ_VERSION 8
#define SZ_DFLAG 1
#define SZ_NAME 115
#define SZ_SIZE 12
-#define HDR_NAME (0)
+#define HDR_NAME (0)
#define HDR_DFLAG (HDR_NAME + SZ_NAME)
#define HDR_SIZE (HDR_DFLAG + SZ_DFLAG)
#define HDR_END (HDR_SIZE + SZ_SIZE)
#define DIR_FLAG (100)
#define FILE_FLAG (102);
+
+#define LOG(level, format, ...) do { if (s_verbose & EXAR_VERBOSE_L##level) \
+ fprintf(stderr, "exar-log%d: "format, level, __VA_ARGS__); } while(0)
+
static size_t s_offset;
static FILE *s_out;
static unsigned char s_verbose = 0;
-#define LOG(level, format, ...) do { if (s_verbose & EXAR_VERBOSE_L##level) \
- fprintf(stderr, "exar-log%d: "format, level, __VA_ARGS__); } while(0)
static int
pack(const char *fpath, const struct stat *st, int tf)
@@ -158,9 +162,17 @@ exar_unpack(const char *path, const char *dest)
fprintf(stderr, "Not an exar file?\n");
return -1;
}
- LOG(1, "Found version %s\n", version);
memcpy(orig_version, VERSION, sizeof(orig_version));
+
+ LOG(2, "Checking filetype%s", "\n");
+ if (strncmp((char*)version, VERSION_BASE, 5))
+ {
+ fprintf(stderr, "Not an exar file?\n");
+ return -1;
+ }
+
+ LOG(1, "Found version %s\n", version);
if (memcmp(version, orig_version, SZ_VERSION))
{
fprintf(stderr, "Incompatible version number\n");