mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-18 06:08:16 +00:00
Merge pull request #1070 from philsmd/master
file locking: check return value of fcntl ()
This commit is contained in:
commit
8f96dc92ae
@ -74,6 +74,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 Locking: Improved error detection on file locks
|
||||
- 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
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
int lock_file (FILE *fp);
|
||||
void unlock_file (FILE *fp);
|
||||
int lock_file (FILE *fp);
|
||||
int unlock_file (FILE *fp);
|
||||
|
||||
#endif // _LOCKING_H
|
||||
|
@ -27,7 +27,7 @@ int lock_file (FILE *fp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void unlock_file (FILE *fp)
|
||||
int unlock_file (FILE *fp)
|
||||
{
|
||||
struct flock lock;
|
||||
|
||||
@ -35,7 +35,12 @@ void unlock_file (FILE *fp)
|
||||
|
||||
lock.l_type = F_UNLCK;
|
||||
|
||||
fcntl (fileno (fp), F_SETLK, &lock);
|
||||
if (fcntl (fileno (fp), F_SETLK, &lock))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
@ -47,7 +52,7 @@ int lock_file (MAYBE_UNUSED FILE *fp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void unlock_file (MAYBE_UNUSED FILE *fp)
|
||||
int unlock_file (MAYBE_UNUSED FILE *fp)
|
||||
{
|
||||
// we should put windows specific code here
|
||||
}
|
||||
|
@ -163,7 +163,10 @@ void loopback_write_append (hashcat_ctx_t *hashcat_ctx, const u8 *plain_ptr, con
|
||||
|
||||
fflush (fp);
|
||||
|
||||
unlock_file (fp);
|
||||
if (unlock_file (fp))
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: Failed to unlock file", loopback_ctx->filename);
|
||||
}
|
||||
|
||||
loopback_ctx->unused = false;
|
||||
}
|
||||
|
@ -271,7 +271,10 @@ void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 *
|
||||
|
||||
fflush (potfile_ctx->fp);
|
||||
|
||||
unlock_file (potfile_ctx->fp);
|
||||
if (unlock_file (potfile_ctx->fp))
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s: Failed to unlock file", potfile_ctx->filename);
|
||||
}
|
||||
}
|
||||
|
||||
void potfile_update_hash (hashcat_ctx_t *hashcat_ctx, hash_t *found, char *line_pw_buf, int line_pw_len)
|
||||
|
Loading…
Reference in New Issue
Block a user