diff --git a/docs/changes.txt b/docs/changes.txt index 249b06367..bb47ae41d 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -77,6 +77,7 @@ - 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 +- File Reads: Fixed memory leak in case outfile or hashfile was not accessible - File Locking: Improved error detection on file locks - Hash Parsing: Added additional bound checks for the SIP digest authentication (MD5) parser (-m 11400) - Sessions: Move out handling of multiple instance from restore file into separate pidfile diff --git a/src/user_options.c b/src/user_options.c index 6a52a900f..50d828093 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -1568,25 +1568,41 @@ int user_options_check_files (hashcat_ctx_t *hashcat_ctx) hc_stat_t tmpstat_outfile = { 0 }; hc_stat_t tmpstat_hashfile = { 0 }; + int do_check = 0; + FILE *tmp_outfile_fp = fopen (outfile, "r"); if (tmp_outfile_fp) { - if (hc_fstat (fileno (tmp_outfile_fp), &tmpstat_outfile)) return -1; + if (hc_fstat (fileno (tmp_outfile_fp), &tmpstat_outfile)) + { + fclose (tmp_outfile_fp); + + return -1; + } fclose (tmp_outfile_fp); + + do_check++; } FILE *tmp_hashfile_fp = fopen (hashfile, "r"); if (tmp_hashfile_fp) { - if (hc_fstat (fileno (tmp_hashfile_fp), &tmpstat_hashfile)) return -1; + if (hc_fstat (fileno (tmp_hashfile_fp), &tmpstat_hashfile)) + { + fclose (tmp_hashfile_fp); + + return -1; + } fclose (tmp_hashfile_fp); + + do_check++; } - if (tmp_outfile_fp) + if (do_check == 2) { tmpstat_outfile.st_mode = 0; tmpstat_outfile.st_nlink = 0;