diff -r c3722fff46c7 -r 8087224f30c4 librazor/uri-io.c --- a/librazor/uri-io.c Fri Jul 08 15:54:09 2016 +0100 +++ b/librazor/uri-io.c Fri Jul 08 17:12:16 2016 +0100 @@ -55,12 +55,13 @@ #define strcmp0(s1, s2) ((s1) && (s2) ? strcmp(s1, s2) : \ (s1) ? 1 : (s2) ? -1 : 0) -#if HAVE_LIBARCHIVE static void * razor_archive_get_file_contents(const char *filename, int fd, const char *path, size_t *length, struct razor_error **error) { +#if HAVE_LIBARCHIVE int r; + const char *errmsg; void *addr; const void *buf; size_t size; @@ -75,8 +76,14 @@ r = archive_read_open_fd(a, fd, 10240); if (r) { - razor_set_error(error, RAZOR_POSIX_ERROR, archive_errno(a), - filename, archive_error_string(a)); + errmsg = archive_error_string(a); + if (!strcmp(errmsg, "Unrecognized archive format")) + razor_set_error(error, RAZOR_GENERAL_ERROR, + RAZOR_GENERAL_ERROR_UNSUPPORTED_ARCHIVE, + filename, errmsg); + else + razor_set_error(error, RAZOR_POSIX_ERROR, + archive_errno(a), filename, errmsg); archive_read_finish(a); return NULL; } @@ -138,6 +145,13 @@ "No such file or directory in archive"); return NULL; +#else + razor_set_error(error, RAZOR_GENERAL_ERROR, + RAZOR_GENERAL_ERROR_UNSUPPORTED_ARCHIVE, + filename, "Archives are not supported in this build"); + + return NULL; +#endif /* HAVE_LIBARCHIVE */ } static void * @@ -147,6 +161,7 @@ int fd; char *path, *slash, *s; void *addr; + struct razor_error *tmp_error = NULL; path = strdup(filename); slash = strrchr(path, '/'); @@ -157,7 +172,8 @@ if (fd >= 0) { addr = razor_archive_get_file_contents(path, fd, slash + 1, - length, error); + length, + error); free(path); close(fd); return addr; @@ -185,7 +201,6 @@ #endif return NULL; } -#endif #define OPEN_FILE_USED (1U<<0) #define OPEN_FILE_MMAPPED (1U<<1) @@ -210,7 +225,6 @@ fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) { -#if HAVE_LIBARCHIVE #ifdef MSWIN_API if (errno != ENOTDIR && errno != ENOENT) { #else @@ -222,10 +236,6 @@ addr = razor_file_get_contents_archive(filename, &size, error); if (!addr) return NULL; -#else - razor_set_error_posix(error, filename); - return NULL; -#endif } else { if (fstat(fd, &st) < 0) { razor_set_error_posix(error, filename);