1.1 --- a/librazor/uri-io.c Fri Jul 08 15:54:09 2016 +0100
1.2 +++ b/librazor/uri-io.c Fri Jul 08 17:12:16 2016 +0100
1.3 @@ -55,12 +55,13 @@
1.4 #define strcmp0(s1, s2) ((s1) && (s2) ? strcmp(s1, s2) : \
1.5 (s1) ? 1 : (s2) ? -1 : 0)
1.6
1.7 -#if HAVE_LIBARCHIVE
1.8 static void *
1.9 razor_archive_get_file_contents(const char *filename, int fd, const char *path,
1.10 size_t *length, struct razor_error **error)
1.11 {
1.12 +#if HAVE_LIBARCHIVE
1.13 int r;
1.14 + const char *errmsg;
1.15 void *addr;
1.16 const void *buf;
1.17 size_t size;
1.18 @@ -75,8 +76,14 @@
1.19 r = archive_read_open_fd(a, fd, 10240);
1.20
1.21 if (r) {
1.22 - razor_set_error(error, RAZOR_POSIX_ERROR, archive_errno(a),
1.23 - filename, archive_error_string(a));
1.24 + errmsg = archive_error_string(a);
1.25 + if (!strcmp(errmsg, "Unrecognized archive format"))
1.26 + razor_set_error(error, RAZOR_GENERAL_ERROR,
1.27 + RAZOR_GENERAL_ERROR_UNSUPPORTED_ARCHIVE,
1.28 + filename, errmsg);
1.29 + else
1.30 + razor_set_error(error, RAZOR_POSIX_ERROR,
1.31 + archive_errno(a), filename, errmsg);
1.32 archive_read_finish(a);
1.33 return NULL;
1.34 }
1.35 @@ -138,6 +145,13 @@
1.36 "No such file or directory in archive");
1.37
1.38 return NULL;
1.39 +#else
1.40 + razor_set_error(error, RAZOR_GENERAL_ERROR,
1.41 + RAZOR_GENERAL_ERROR_UNSUPPORTED_ARCHIVE,
1.42 + filename, "Archives are not supported in this build");
1.43 +
1.44 + return NULL;
1.45 +#endif /* HAVE_LIBARCHIVE */
1.46 }
1.47
1.48 static void *
1.49 @@ -147,6 +161,7 @@
1.50 int fd;
1.51 char *path, *slash, *s;
1.52 void *addr;
1.53 + struct razor_error *tmp_error = NULL;
1.54
1.55 path = strdup(filename);
1.56 slash = strrchr(path, '/');
1.57 @@ -157,7 +172,8 @@
1.58 if (fd >= 0) {
1.59 addr = razor_archive_get_file_contents(path, fd,
1.60 slash + 1,
1.61 - length, error);
1.62 + length,
1.63 + error);
1.64 free(path);
1.65 close(fd);
1.66 return addr;
1.67 @@ -185,7 +201,6 @@
1.68 #endif
1.69 return NULL;
1.70 }
1.71 -#endif
1.72
1.73 #define OPEN_FILE_USED (1U<<0)
1.74 #define OPEN_FILE_MMAPPED (1U<<1)
1.75 @@ -210,7 +225,6 @@
1.76
1.77 fd = open(filename, O_RDONLY | O_BINARY);
1.78 if (fd < 0) {
1.79 -#if HAVE_LIBARCHIVE
1.80 #ifdef MSWIN_API
1.81 if (errno != ENOTDIR && errno != ENOENT) {
1.82 #else
1.83 @@ -222,10 +236,6 @@
1.84 addr = razor_file_get_contents_archive(filename, &size, error);
1.85 if (!addr)
1.86 return NULL;
1.87 -#else
1.88 - razor_set_error_posix(error, filename);
1.89 - return NULL;
1.90 -#endif
1.91 } else {
1.92 if (fstat(fd, &st) < 0) {
1.93 razor_set_error_posix(error, filename);