if (ENABLE_FEATURE_SEAMLESS_LZMA) {
/* .lzma has no header/signature, can only detect it by extension */
- char *sfx = strrchr(fname, '.');
- if (sfx && strcmp(sfx+1, "lzma") == 0) {
+ if (is_suffixed_with(fname, ".lzma")) {
xstate = xzalloc(sizeof(*xstate));
xstate->src_fd = fd;
xstate->xformer = unpack_lzma_stream;
tar_handle->seek = seek_by_read;
} else
if (ENABLE_FEATURE_TAR_AUTODETECT
+ && ENABLE_FEATURE_SEAMLESS_LZMA
&& flags == O_RDONLY
&& !(opt & OPT_ANY_COMPRESS)
+ && is_suffixed_with(tar_filename, ".lzma")
+ /* We do this only for .lzma files, they have no signature.
+ * All other compression formats are recognized in
+ * get_header_tar() when first tar block has invalid format.
+ * Doing it here for all filenames would falsely trigger
+ * on e.g. tarball with 1st file named "BZh5".
+ */
) {
tar_handle->src_fd = open_zipped(tar_filename, /*fail_if_not_compressed:*/ 0);
if (tar_handle->src_fd < 0)
parser_t *p;
struct module_entry *m;
int rc = TRUE;
- const char *base, *ext;
+ const char *base;
/* Skip files that begin with a "." */
base = bb_basename(filename);
* "include FILE_NOT_ENDING_IN_CONF" must work too.
*/
if (depth != 0) {
- ext = strrchr(base, '.');
- if (ext == NULL || strcmp(ext + 1, "conf"))
+ if (!is_suffixed_with(base, ".conf"))
goto error;
}