From c1b89fb2ac3a65db93d4b5a393e534f471d7b022 Mon Sep 17 00:00:00 2001 From: philsmd Date: Tue, 14 Feb 2017 13:57:24 +0100 Subject: [PATCH] added return code check whenever fstat () was called --- docs/changes.txt | 1 + src/outfile_check.c | 2 +- src/user_options.c | 4 ++-- src/wordlist.c | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index d2b740fe2..51c246cbc 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -69,6 +69,7 @@ - OpenCL Runtime: Updated AMDGPU-Pro driver version check, do warn if version 16.60 is detected which is known to be broken - OpenCL Kernel: Renumbered hash-mode 7600 to 4521 - OpenCL Device: Do a check on available constant memory size and abort if it's less than 64kB +- File Reads: Improved error detection on file reads, especially when getting the file stats - Sessions: Move out handling of multiple instance from restore file into separate pidfile - Threads: Restored strerror as %m is unsupported by the BSDs - Wordlists: Disable dictstat handling for hash-mode 3000 as it virtually creates words in the wordlist which is not the case for other modes diff --git a/src/outfile_check.c b/src/outfile_check.c index 445b832a7..d564238da 100644 --- a/src/outfile_check.c +++ b/src/outfile_check.c @@ -141,7 +141,7 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx) hc_stat_t outfile_stat; - hc_fstat (fileno (fp), &outfile_stat); + if (hc_fstat (fileno (fp), &outfile_stat)) continue; if (outfile_stat.st_ctime > out_info[j].ctime) { diff --git a/src/user_options.c b/src/user_options.c index b351e3952..6a52a900f 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -1572,7 +1572,7 @@ int user_options_check_files (hashcat_ctx_t *hashcat_ctx) if (tmp_outfile_fp) { - hc_fstat (fileno (tmp_outfile_fp), &tmpstat_outfile); + if (hc_fstat (fileno (tmp_outfile_fp), &tmpstat_outfile)) return -1; fclose (tmp_outfile_fp); } @@ -1581,7 +1581,7 @@ int user_options_check_files (hashcat_ctx_t *hashcat_ctx) if (tmp_hashfile_fp) { - hc_fstat (fileno (tmp_hashfile_fp), &tmpstat_hashfile); + if (hc_fstat (fileno (tmp_hashfile_fp), &tmpstat_hashfile)) return -1; fclose (tmp_hashfile_fp); } diff --git a/src/wordlist.c b/src/wordlist.c index 2d5903d3c..08a6a98be 100644 --- a/src/wordlist.c +++ b/src/wordlist.c @@ -285,7 +285,7 @@ u64 count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile) d.cnt = 0; - hc_fstat (fileno (fd), &d.stat); + if (hc_fstat (fileno (fd), &d.stat)) return 0; d.stat.st_mode = 0; d.stat.st_nlink = 0;