diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/sysdefs.h | 15 | ||||
| -rw-r--r-- | src/liblzma/api/lzma/lzma.h | 3 | ||||
| -rw-r--r-- | src/liblzma/api/lzma/version.h | 2 | ||||
| -rw-r--r-- | src/liblzma/common/common.h | 2 | ||||
| -rw-r--r-- | src/xz/file_io.c | 15 | ||||
| -rw-r--r-- | src/xz/suffix.c | 33 | ||||
| -rw-r--r-- | src/xz/util.h | 5 |
7 files changed, 59 insertions, 16 deletions
diff --git a/src/common/sysdefs.h b/src/common/sysdefs.h index c74c6212cff57..69370ba421069 100644 --- a/src/common/sysdefs.h +++ b/src/common/sysdefs.h @@ -65,6 +65,9 @@ #ifndef PRIu32 # define PRIu32 "u" #endif +#ifndef PRIx32 +# define PRIx32 "x" +#endif #ifndef PRIX32 # define PRIX32 "X" #endif @@ -76,6 +79,9 @@ # ifndef PRIu64 # define PRIu64 "llu" # endif +# ifndef PRIx64 +# define PRIx64 "llx" +# endif # ifndef PRIX64 # define PRIX64 "llX" # endif @@ -86,6 +92,9 @@ # ifndef PRIu64 # define PRIu64 "lu" # endif +# ifndef PRIx64 +# define PRIx64 "lx" +# endif # ifndef PRIX64 # define PRIX64 "lX" # endif @@ -171,4 +180,10 @@ typedef unsigned char _Bool; # define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) #endif +#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4 +# define lzma_attr_alloc_size(x) __attribute__((__alloc_size__(x))) +#else +# define lzma_attr_alloc_size(x) +#endif + #endif diff --git a/src/liblzma/api/lzma/lzma.h b/src/liblzma/api/lzma/lzma.h index 8d5fdb6e5cad5..3f8e095f70e8d 100644 --- a/src/liblzma/api/lzma/lzma.h +++ b/src/liblzma/api/lzma/lzma.h @@ -412,6 +412,9 @@ typedef struct { * * This function is available only if LZMA1 or LZMA2 encoder has been enabled * when building liblzma. + * + * \return On success, false is returned. If the preset is not + * supported, true is returned. */ extern LZMA_API(lzma_bool) lzma_lzma_preset( lzma_options_lzma *options, uint32_t preset) lzma_nothrow; diff --git a/src/liblzma/api/lzma/version.h b/src/liblzma/api/lzma/version.h index 25e8a8201fafd..43c211fa960da 100644 --- a/src/liblzma/api/lzma/version.h +++ b/src/liblzma/api/lzma/version.h @@ -22,7 +22,7 @@ */ #define LZMA_VERSION_MAJOR 5 #define LZMA_VERSION_MINOR 0 -#define LZMA_VERSION_PATCH 0 +#define LZMA_VERSION_PATCH 1 #define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE #ifndef LZMA_VERSION_COMMIT diff --git a/src/liblzma/common/common.h b/src/liblzma/common/common.h index 3a85168f13b95..b819432371d46 100644 --- a/src/liblzma/common/common.h +++ b/src/liblzma/common/common.h @@ -205,7 +205,7 @@ struct lzma_internal_s { /// Allocates memory extern void *lzma_alloc(size_t size, lzma_allocator *allocator) - lzma_attribute((malloc)); + lzma_attribute((malloc)) lzma_attr_alloc_size(1); /// Frees memory extern void lzma_free(void *ptr, lzma_allocator *allocator); diff --git a/src/xz/file_io.c b/src/xz/file_io.c index 6e24c58a945c8..09edcca69eb40 100644 --- a/src/xz/file_io.c +++ b/src/xz/file_io.c @@ -457,15 +457,14 @@ io_open_src_real(file_pair *pair) goto error; } - if (reg_files_only) { - if (!S_ISREG(pair->src_st.st_mode)) { - message_warning(_("%s: Not a regular file, " - "skipping"), pair->src_name); - goto error; - } + if (reg_files_only && !S_ISREG(pair->src_st.st_mode)) { + message_warning(_("%s: Not a regular file, skipping"), + pair->src_name); + goto error; + } - // These are meaningless on Windows. #ifndef TUKLIB_DOSLIKE + if (reg_files_only && !opt_force) { if (pair->src_st.st_mode & (S_ISUID | S_ISGID)) { // gzip rejects setuid and setgid files even // when --force was used. bzip2 doesn't check @@ -495,8 +494,8 @@ io_open_src_real(file_pair *pair) "skipping"), pair->src_name); goto error; } -#endif } +#endif return false; diff --git a/src/xz/suffix.c b/src/xz/suffix.c index f2a2da2749b15..ea86c1a3f6b93 100644 --- a/src/xz/suffix.c +++ b/src/xz/suffix.c @@ -27,6 +27,30 @@ struct suffix_pair { }; +/// \brief Test if the char is a directory separator +static bool +is_dir_sep(char c) +{ +#ifdef TUKLIB_DOSLIKE + return c == '/' || c == '\\' || c == ':'; +#else + return c == '/'; +#endif +} + + +/// \brief Test if the string contains a directory separator +static bool +has_dir_sep(const char *str) +{ +#ifdef TUKLIB_DOSLIKE + return strpbrk(str, "/\\:") != NULL; +#else + return strchr(str, '/') != NULL; +#endif +} + + /// \brief Checks if src_name has given compressed_suffix /// /// \param suffix Filename suffix to look for @@ -44,7 +68,8 @@ test_suffix(const char *suffix, const char *src_name, size_t src_len) // The filename must have at least one character in addition to // the suffix. src_name may contain path to the filename, so we // need to check for directory separator too. - if (src_len <= suffix_len || src_name[src_len - suffix_len - 1] == '/') + if (src_len <= suffix_len + || is_dir_sep(src_name[src_len - suffix_len - 1])) return 0; if (strcmp(suffix, src_name + src_len - suffix_len) == 0) @@ -199,9 +224,9 @@ suffix_get_dest_name(const char *src_name) extern void suffix_set(const char *suffix) { - // Empty suffix and suffixes having a slash are rejected. Such - // suffixes would break things later. - if (suffix[0] == '\0' || strchr(suffix, '/') != NULL) + // Empty suffix and suffixes having a directory separator are + // rejected. Such suffixes would break things later. + if (suffix[0] == '\0' || has_dir_sep(suffix)) message_fatal(_("%s: Invalid filename suffix"), optarg); // Replace the old custom_suffix (if any) with the new suffix. diff --git a/src/xz/util.h b/src/xz/util.h index fea8cc6695dce..4b2d3e2f573fa 100644 --- a/src/xz/util.h +++ b/src/xz/util.h @@ -19,11 +19,12 @@ /// \brief Safe realloc() that never returns NULL -extern void *xrealloc(void *ptr, size_t size); +extern void *xrealloc(void *ptr, size_t size) + lzma_attribute((malloc)) lzma_attr_alloc_size(2); /// \brief Safe strdup() that never returns NULL -extern char *xstrdup(const char *src); +extern char *xstrdup(const char *src) lzma_attribute((malloc)); /// \brief Fancy version of strtoull() |
