diff --git a/src/filehandling.c b/src/filehandling.c index bda39a5e5..9c8acf599 100644 --- a/src/filehandling.c +++ b/src/filehandling.c @@ -116,28 +116,32 @@ bool hc_fopen (HCFILE *fp, const char *path, const char *mode) bool is_gzip = false; bool is_zip = false; bool is_xz = false; + bool is_fifo = hc_path_is_fifo (path); - int fd_tmp = open (path, O_RDONLY); - - if (fd_tmp != -1) + if (is_fifo == false) { - lseek (fd_tmp, 0, SEEK_SET); + int fd_tmp = open (path, O_RDONLY); - if (read (fd_tmp, check, sizeof (check)) > 0) + if (fd_tmp != -1) { - if (check[0] == 0x1f && check[1] == 0x8b && check[2] == 0x08) is_gzip = true; - if (check[0] == 0x50 && check[1] == 0x4b && check[2] == 0x03 && check[3] == 0x04) is_zip = true; - if (memcmp (check, XZ_SIG, XZ_SIG_SIZE) == 0) is_xz = true; + lseek (fd_tmp, 0, SEEK_SET); - // compressed files with BOM will be undetected! - - if (is_gzip == false && is_zip == false && is_xz == false) + if (read (fd_tmp, check, sizeof (check)) > 0) { - fp->bom_size = hc_string_bom_size (check); - } - } + if (check[0] == 0x1f && check[1] == 0x8b && check[2] == 0x08) is_gzip = true; + if (check[0] == 0x50 && check[1] == 0x4b && check[2] == 0x03 && check[3] == 0x04) is_zip = true; + if (memcmp (check, XZ_SIG, XZ_SIG_SIZE) == 0) is_xz = true; - close (fd_tmp); + // compressed files with BOM will be undetected! + + if (is_gzip == false && is_zip == false && is_xz == false) + { + fp->bom_size = hc_string_bom_size (check); + } + } + + close (fd_tmp); + } } if (fmode == -1) diff --git a/src/shared.c b/src/shared.c index 79b56e5c7..f15ef23b8 100644 --- a/src/shared.c +++ b/src/shared.c @@ -699,6 +699,11 @@ bool hc_same_files (char *file1, char *file2) { if ((file1 != NULL) && (file2 != NULL)) { + if (hc_path_is_fifo (file1) == true || hc_path_is_fifo (file2) == true) + { + return false; + } + struct stat tmpstat_file1; struct stat tmpstat_file2; diff --git a/src/user_options.c b/src/user_options.c index 48dd0033a..4dd2dce39 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -2731,13 +2731,6 @@ int user_options_check_files (hashcat_ctx_t *hashcat_ctx) { if (hc_path_exist (outfile_ctx->filename) == true) { - if (hc_path_is_fifo (outfile_ctx->filename) == true) - { - event_log_error (hashcat_ctx, "%s: A fifo cannot be used as an outfile.", outfile_ctx->filename); - - return -1; - } - if (hc_path_is_directory (outfile_ctx->filename) == true) { event_log_error (hashcat_ctx, "%s: A directory cannot be used as an outfile.", outfile_ctx->filename);