1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-26 09:58:16 +00:00

Fix some old GCC compiler warnings

This commit is contained in:
jsteube 2017-07-06 10:35:25 +02:00
parent 819b53eb1d
commit 8abd7ae9d1
23 changed files with 86 additions and 62 deletions

View File

@ -8,7 +8,7 @@
#define PROGNAME "hashcat" #define PROGNAME "hashcat"
#if defined (__unix__) || defined (__APPLE__) #if defined (__unix__) || defined (__APPLE__)
#define _POSIX #define _POSIX
#elif defined (__WINNT__) #elif defined (__WINNT__)
#define _WIN 1 #define _WIN 1
@ -16,9 +16,11 @@
#error Your Operating System is not supported or detected #error Your Operating System is not supported or detected
#endif #endif
#if defined (__BYTE_ORDER__) && defined (__ORDER_BIG_ENDIAN__)
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#error "compiling for big-endian architecture not supported" #error "compiling for big-endian architecture not supported"
#endif #endif
#endif
#ifndef _GNU_SOURCE #ifndef _GNU_SOURCE
#define _GNU_SOURCE #define _GNU_SOURCE

View File

@ -59,4 +59,7 @@ bool hc_string_is_digit (const char *s);
void hc_string_trim_trailing (char *s); void hc_string_trim_trailing (char *s);
void hc_string_trim_leading (char *s); void hc_string_trim_leading (char *s);
size_t hc_fread (void *ptr, size_t size, size_t nmemb, FILE *stream);
void hc_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream);
#endif // _SHARED_H #endif // _SHARED_H

View File

@ -144,7 +144,6 @@ CFLAGS += -Wpointer-arith
CFLAGS += -Wstrict-prototypes CFLAGS += -Wstrict-prototypes
CFLAGS += -Waggregate-return CFLAGS += -Waggregate-return
CFLAGS += -Wswitch-enum CFLAGS += -Wswitch-enum
CFLAGS += -Wunreachable-code
CFLAGS += -Winit-self CFLAGS += -Winit-self
CFLAGS += -Werror-implicit-function-declaration CFLAGS += -Werror-implicit-function-declaration
CFLAGS += -Wformat CFLAGS += -Wformat

View File

@ -7,6 +7,7 @@
#include "types.h" #include "types.h"
#include "memory.h" #include "memory.h"
#include "event.h" #include "event.h"
#include "shared.h"
#include "cpu_crc32.h" #include "cpu_crc32.h"
static const u32 crc32tab[256] = static const u32 crc32tab[256] =
@ -106,7 +107,7 @@ int cpu_crc32 (hashcat_ctx_t *hashcat_ctx, const char *filename, u8 keytab[64])
u8 *buf = (u8 *) hcmalloc (MAX_KEY_SIZE + 1); u8 *buf = (u8 *) hcmalloc (MAX_KEY_SIZE + 1);
size_t nread = fread (buf, sizeof (u8), MAX_KEY_SIZE, fd); size_t nread = hc_fread (buf, sizeof (u8), MAX_KEY_SIZE, fd);
fclose (fd); fclose (fd);

View File

@ -8,6 +8,7 @@
#include "memory.h" #include "memory.h"
#include "event.h" #include "event.h"
#include "debugfile.h" #include "debugfile.h"
#include "shared.h"
#include "locking.h" #include "locking.h"
static void debugfile_format_plain (hashcat_ctx_t *hashcat_ctx, const u8 *plain_ptr, const u32 plain_len) static void debugfile_format_plain (hashcat_ctx_t *hashcat_ctx, const u8 *plain_ptr, const u32 plain_len)
@ -48,7 +49,7 @@ static void debugfile_format_plain (hashcat_ctx_t *hashcat_ctx, const u8 *plain_
} }
else else
{ {
fwrite (plain_ptr, plain_len, 1, debugfile_ctx->fp); hc_fwrite (plain_ptr, plain_len, 1, debugfile_ctx->fp);
} }
} }
@ -67,7 +68,7 @@ void debugfile_write_append (hashcat_ctx_t *hashcat_ctx, const u8 *rule_buf, con
if ((debug_mode == 3) || (debug_mode == 4)) fputc (':', debugfile_ctx->fp); if ((debug_mode == 3) || (debug_mode == 4)) fputc (':', debugfile_ctx->fp);
} }
fwrite (rule_buf, rule_len, 1, debugfile_ctx->fp); hc_fwrite (rule_buf, rule_len, 1, debugfile_ctx->fp);
if (debug_mode == 4) if (debug_mode == 4)
{ {
@ -76,7 +77,7 @@ void debugfile_write_append (hashcat_ctx_t *hashcat_ctx, const u8 *rule_buf, con
debugfile_format_plain (hashcat_ctx, mod_plain_ptr, mod_plain_len); debugfile_format_plain (hashcat_ctx, mod_plain_ptr, mod_plain_len);
} }
fwrite (EOL, strlen (EOL), 1, debugfile_ctx->fp); hc_fwrite (EOL, strlen (EOL), 1, debugfile_ctx->fp);
} }
int debugfile_init (hashcat_ctx_t *hashcat_ctx) int debugfile_init (hashcat_ctx_t *hashcat_ctx)

View File

@ -89,7 +89,7 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx)
{ {
dictstat_t d; dictstat_t d;
const size_t nread = fread (&d, sizeof (dictstat_t), 1, fp); const size_t nread = hc_fread (&d, sizeof (dictstat_t), 1, fp);
if (nread == 0) continue; if (nread == 0) continue;
@ -130,7 +130,7 @@ int dictstat_write (hashcat_ctx_t *hashcat_ctx)
return -1; return -1;
} }
fwrite (dictstat_ctx->base, sizeof (dictstat_t), dictstat_ctx->cnt, fp); hc_fwrite (dictstat_ctx->base, sizeof (dictstat_t), dictstat_ctx->cnt, fp);
fclose (fp); fclose (fp);

View File

@ -6,6 +6,7 @@
#include "common.h" #include "common.h"
#include "types.h" #include "types.h"
#include "memory.h" #include "memory.h"
#include "shared.h"
#include "filehandling.h" #include "filehandling.h"
u64 count_lines (FILE *fd) u64 count_lines (FILE *fd)
@ -18,7 +19,7 @@ u64 count_lines (FILE *fd)
while (!feof (fd)) while (!feof (fd))
{ {
size_t nread = fread (buf, sizeof (char), HCBUFSIZ_LARGE, fd); size_t nread = hc_fread (buf, sizeof (char), HCBUFSIZ_LARGE, fd);
if (nread < 1) continue; if (nread < 1) continue;

View File

@ -171,7 +171,7 @@ int save_hash (hashcat_ctx_t *hashcat_ctx)
to_hccapx_t (hashcat_ctx, &hccapx, salt_pos, digest_pos); to_hccapx_t (hashcat_ctx, &hccapx, salt_pos, digest_pos);
fwrite (&hccapx, sizeof (hccapx_t), 1, fp); hc_fwrite (&hccapx, sizeof (hccapx_t), 1, fp);
} }
else else
{ {
@ -753,7 +753,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
while (!feof (fp)) while (!feof (fp))
{ {
const size_t nread = fread (in, sizeof (hccapx_t), 1, fp); const size_t nread = hc_fread (in, sizeof (hccapx_t), 1, fp);
if (nread == 0) break; if (nread == 0) break;
@ -1579,11 +1579,11 @@ int hashes_init_selftest (hashcat_ctx_t *hashcat_ctx)
} }
else if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE) else if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE)
{ {
char *tmpfile = (char *) hcmalloc (HCBUFSIZ_TINY); char *tmpfile_bin = (char *) hcmalloc (HCBUFSIZ_TINY);
snprintf (tmpfile, HCBUFSIZ_TINY - 1, "%s/selftest.hash", folder_config->session_dir); snprintf (tmpfile_bin, HCBUFSIZ_TINY - 1, "%s/selftest.hash", folder_config->session_dir);
FILE *fp = fopen (tmpfile, "wb"); FILE *fp = fopen (tmpfile_bin, "wb");
const int st_hash_len = strlen (hashconfig->st_hash); const int st_hash_len = strlen (hashconfig->st_hash);
@ -1596,11 +1596,11 @@ int hashes_init_selftest (hashcat_ctx_t *hashcat_ctx)
fclose (fp); fclose (fp);
parser_status = hashconfig->parse_func ((u8 *) tmpfile, strlen (tmpfile), &hash, hashconfig); parser_status = hashconfig->parse_func ((u8 *) tmpfile_bin, strlen (tmpfile_bin), &hash, hashconfig);
unlink (tmpfile); unlink (tmpfile_bin);
hcfree (tmpfile); hcfree (tmpfile_bin);
} }
else else
{ {

View File

@ -616,7 +616,7 @@ static int nvml_init (hashcat_ctx_t *hashcat_ctx)
nvml_winpath = (char *) hcmalloc (100); nvml_winpath = (char *) hcmalloc (100);
fread (nvml_winpath, 100, 1, nvml_lib); hc_fread (nvml_winpath, 100, 1, nvml_lib);
fclose (nvml_lib); fclose (nvml_lib);

View File

@ -18,6 +18,7 @@
#include "cpu_sha1.h" #include "cpu_sha1.h"
#include "cpu_sha256.h" #include "cpu_sha256.h"
#include "cpu_blake2.h" #include "cpu_blake2.h"
#include "shared.h"
#include "interface.h" #include "interface.h"
#include "ext_lzma.h" #include "ext_lzma.h"
@ -3491,7 +3492,7 @@ int psafe2_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNU
memset (&buf, 0, sizeof (psafe2_hdr)); memset (&buf, 0, sizeof (psafe2_hdr));
const size_t n = fread (&buf, sizeof (psafe2_hdr), 1, fp); const size_t n = hc_fread (&buf, sizeof (psafe2_hdr), 1, fp);
fclose (fp); fclose (fp);
@ -3528,7 +3529,7 @@ int psafe3_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNU
memset (&in, 0, sizeof (psafe3_t)); memset (&in, 0, sizeof (psafe3_t));
const size_t n = fread (&in, sizeof (psafe3_t), 1, fp); const size_t n = hc_fread (&in, sizeof (psafe3_t), 1, fp);
fclose (fp); fclose (fp);
@ -6188,7 +6189,7 @@ int truecrypt_parse_hash_1k (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAY
char buf[512] = { 0 }; char buf[512] = { 0 };
const size_t n = fread (buf, 1, sizeof (buf), fp); const size_t n = hc_fread (buf, 1, sizeof (buf), fp);
fclose (fp); fclose (fp);
@ -6227,7 +6228,7 @@ int truecrypt_parse_hash_2k (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAY
char buf[512] = { 0 }; char buf[512] = { 0 };
const size_t n = fread (buf, 1, sizeof (buf), fp); const size_t n = hc_fread (buf, 1, sizeof (buf), fp);
fclose (fp); fclose (fp);
@ -6266,7 +6267,7 @@ int veracrypt_parse_hash_200000 (u8 *input_buf, u32 input_len, hash_t *hash_buf,
char buf[512] = { 0 }; char buf[512] = { 0 };
const size_t n = fread (buf, 1, sizeof (buf), fp); const size_t n = hc_fread (buf, 1, sizeof (buf), fp);
fclose (fp); fclose (fp);
@ -6305,7 +6306,7 @@ int veracrypt_parse_hash_500000 (u8 *input_buf, u32 input_len, hash_t *hash_buf,
char buf[512] = { 0 }; char buf[512] = { 0 };
const size_t n = fread (buf, 1, sizeof (buf), fp); const size_t n = hc_fread (buf, 1, sizeof (buf), fp);
fclose (fp); fclose (fp);
@ -6344,7 +6345,7 @@ int veracrypt_parse_hash_327661 (u8 *input_buf, u32 input_len, hash_t *hash_buf,
char buf[512] = { 0 }; char buf[512] = { 0 };
const size_t n = fread (buf, 1, sizeof (buf), fp); const size_t n = hc_fread (buf, 1, sizeof (buf), fp);
fclose (fp); fclose (fp);
@ -6383,7 +6384,7 @@ int veracrypt_parse_hash_655331 (u8 *input_buf, u32 input_len, hash_t *hash_buf,
char buf[512] = { 0 }; char buf[512] = { 0 };
const size_t n = fread (buf, 1, sizeof (buf), fp); const size_t n = hc_fread (buf, 1, sizeof (buf), fp);
fclose (fp); fclose (fp);
@ -14364,7 +14365,7 @@ int luks_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSE
struct luks_phdr hdr; struct luks_phdr hdr;
const size_t nread = fread (&hdr, sizeof (hdr), 1, fp); const size_t nread = hc_fread (&hdr, sizeof (hdr), 1, fp);
if (nread != 1) if (nread != 1)
{ {
@ -14618,7 +14619,7 @@ int luks_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSE
return (PARSER_LUKS_FILE_SIZE); return (PARSER_LUKS_FILE_SIZE);
} }
const size_t nread2 = fread (luks->af_src_buf, keyBytes, stripes, fp); const size_t nread2 = hc_fread (luks->af_src_buf, keyBytes, stripes, fp);
if (nread2 != stripes) if (nread2 != stripes)
{ {
@ -14640,7 +14641,7 @@ int luks_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSE
return (PARSER_LUKS_FILE_SIZE); return (PARSER_LUKS_FILE_SIZE);
} }
const size_t nread3 = fread (luks->ct_buf, sizeof (u32), 128, fp); const size_t nread3 = hc_fread (luks->ct_buf, sizeof (u32), 128, fp);
if (nread3 != 128) if (nread3 != 128)
{ {
@ -16132,7 +16133,7 @@ int check_old_hccap (const char *hashfile)
u32 signature; u32 signature;
const size_t nread = fread (&signature, sizeof (u32), 1, fp); const size_t nread = hc_fread (&signature, sizeof (u32), 1, fp);
fclose (fp); fclose (fp);

View File

@ -62,7 +62,7 @@ void logfile_append (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
va_end (ap); va_end (ap);
fwrite (EOL, strlen (EOL), 1, fp); hc_fwrite (EOL, strlen (EOL), 1, fp);
fflush (fp); fflush (fp);

View File

@ -49,7 +49,7 @@ static void loopback_format_plain (hashcat_ctx_t *hashcat_ctx, const u8 *plain_p
} }
else else
{ {
fwrite (plain_ptr, plain_len, 1, loopback_ctx->fp); hc_fwrite (plain_ptr, plain_len, 1, loopback_ctx->fp);
} }
} }
@ -159,7 +159,7 @@ void loopback_write_append (hashcat_ctx_t *hashcat_ctx, const u8 *plain_ptr, con
lock_file (fp); lock_file (fp);
fwrite (EOL, strlen (EOL), 1, fp); hc_fwrite (EOL, strlen (EOL), 1, fp);
fflush (fp); fflush (fp);

View File

@ -18,6 +18,7 @@
#include "thread.h" #include "thread.h"
#include "status.h" #include "status.h"
#include "interface.h" #include "interface.h"
#include "shared.h"
#include "event.h" #include "event.h"
#if defined (__MINGW64__) || defined (__MINGW32__) #if defined (__MINGW64__) || defined (__MINGW32__)
@ -97,15 +98,15 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel)
switch (loglevel) switch (loglevel)
{ {
case LOGLEVEL_INFO: break; case LOGLEVEL_INFO: break;
case LOGLEVEL_WARNING: fwrite ("\033[33m", 5, 1, fp); break; case LOGLEVEL_WARNING: hc_fwrite ("\033[33m", 5, 1, fp); break;
case LOGLEVEL_ERROR: fwrite ("\033[31m", 5, 1, fp); break; case LOGLEVEL_ERROR: hc_fwrite ("\033[31m", 5, 1, fp); break;
case LOGLEVEL_ADVICE: fwrite ("\033[33m", 5, 1, fp); break; case LOGLEVEL_ADVICE: hc_fwrite ("\033[33m", 5, 1, fp); break;
} }
#endif #endif
// finally, print // finally, print
fwrite (msg_buf, msg_len, 1, fp); hc_fwrite (msg_buf, msg_len, 1, fp);
// color stuff post // color stuff post
@ -121,9 +122,9 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel)
switch (loglevel) switch (loglevel)
{ {
case LOGLEVEL_INFO: break; case LOGLEVEL_INFO: break;
case LOGLEVEL_WARNING: fwrite ("\033[0m", 4, 1, fp); break; case LOGLEVEL_WARNING: hc_fwrite ("\033[0m", 4, 1, fp); break;
case LOGLEVEL_ERROR: fwrite ("\033[0m", 4, 1, fp); break; case LOGLEVEL_ERROR: hc_fwrite ("\033[0m", 4, 1, fp); break;
case LOGLEVEL_ADVICE: fwrite ("\033[0m", 4, 1, fp); break; case LOGLEVEL_ADVICE: hc_fwrite ("\033[0m", 4, 1, fp); break;
} }
#endif #endif
@ -131,13 +132,13 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel)
if (msg_newline == true) if (msg_newline == true)
{ {
fwrite (EOL, strlen (EOL), 1, fp); hc_fwrite (EOL, strlen (EOL), 1, fp);
// on error, add another newline // on error, add another newline
if (loglevel == LOGLEVEL_ERROR) if (loglevel == LOGLEVEL_ERROR)
{ {
fwrite (EOL, strlen (EOL), 1, fp); hc_fwrite (EOL, strlen (EOL), 1, fp);
} }
} }
@ -323,8 +324,8 @@ static void main_cracker_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx,
if (outfile_ctx->filename == NULL) if (user_options->quiet == false) clear_prompt (); if (outfile_ctx->filename == NULL) if (user_options->quiet == false) clear_prompt ();
} }
fwrite (buf, len, 1, stdout); hc_fwrite (buf, len, 1, stdout);
fwrite (EOL, strlen (EOL), 1, stdout); hc_fwrite (EOL, strlen (EOL), 1, stdout);
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{ {
@ -369,8 +370,8 @@ static void main_potfile_hash_show (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAY
if (outfile_ctx->fp != NULL) return; // cracked hash was not written to an outfile if (outfile_ctx->fp != NULL) return; // cracked hash was not written to an outfile
fwrite (buf, len, 1, stdout); hc_fwrite (buf, len, 1, stdout);
fwrite (EOL, strlen (EOL), 1, stdout); hc_fwrite (EOL, strlen (EOL), 1, stdout);
} }
static void main_potfile_hash_left (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) static void main_potfile_hash_left (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
@ -379,8 +380,8 @@ static void main_potfile_hash_left (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAY
if (outfile_ctx->fp != NULL) return; // cracked hash was not written to an outfile if (outfile_ctx->fp != NULL) return; // cracked hash was not written to an outfile
fwrite (buf, len, 1, stdout); hc_fwrite (buf, len, 1, stdout);
fwrite (EOL, strlen (EOL), 1, stdout); hc_fwrite (EOL, strlen (EOL), 1, stdout);
} }
static void main_potfile_num_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) static void main_potfile_num_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)

View File

@ -571,7 +571,7 @@ static int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr,
{ {
char mp_file[1024] = { 0 }; char mp_file[1024] = { 0 };
const size_t nread = fread (mp_file, 1, sizeof (mp_file) - 1, fp); const size_t nread = hc_fread (mp_file, 1, sizeof (mp_file) - 1, fp);
if (!feof (fp)) if (!feof (fp))
{ {
@ -700,7 +700,7 @@ static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx)
u8 *inbuf = (u8 *) hcmalloc (s.st_size); u8 *inbuf = (u8 *) hcmalloc (s.st_size);
SizeT inlen = (SizeT) fread (inbuf, 1, s.st_size, fd); SizeT inlen = (SizeT) hc_fread (inbuf, 1, s.st_size, fd);
if (inlen != (SizeT) s.st_size) if (inlen != (SizeT) s.st_size)
{ {

View File

@ -363,7 +363,7 @@ static int read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_fi
char *buf = (char *) hcmalloc (st.st_size + 1); char *buf = (char *) hcmalloc (st.st_size + 1);
size_t num_read = fread (buf, sizeof (char), st.st_size, fp); size_t num_read = hc_fread (buf, sizeof (char), st.st_size, fp);
fclose (fp); fclose (fp);
@ -414,7 +414,7 @@ static int write_kernel_binary (hashcat_ctx_t *hashcat_ctx, char *kernel_file, c
return -1; return -1;
} }
fwrite (binary, sizeof (char), binary_size, fp); hc_fwrite (binary, sizeof (char), binary_size, fp);
fflush (fp); fflush (fp);

View File

@ -487,8 +487,8 @@ int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsign
if (outfile_ctx->fp != NULL) if (outfile_ctx->fp != NULL)
{ {
fwrite (tmp_buf, tmp_len, 1, outfile_ctx->fp); hc_fwrite (tmp_buf, tmp_len, 1, outfile_ctx->fp);
fwrite (EOL, strlen (EOL), 1, outfile_ctx->fp); hc_fwrite (EOL, strlen (EOL), 1, outfile_ctx->fp);
} }
return tmp_len; return tmp_len;

View File

@ -23,7 +23,7 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx)
pidfile_data_t *pd = (pidfile_data_t *) hcmalloc (sizeof (pidfile_data_t)); pidfile_data_t *pd = (pidfile_data_t *) hcmalloc (sizeof (pidfile_data_t));
const size_t nread = fread (pd, sizeof (pidfile_data_t), 1, fp); const size_t nread = hc_fread (pd, sizeof (pidfile_data_t), 1, fp);
fclose (fp); fclose (fp);
@ -134,7 +134,7 @@ static int write_pidfile (hashcat_ctx_t *hashcat_ctx)
return -1; return -1;
} }
fwrite (pd, sizeof (pidfile_data_t), 1, fp); hc_fwrite (pd, sizeof (pidfile_data_t), 1, fp);
fflush (fp); fflush (fp);

View File

@ -185,7 +185,7 @@ static int write_restore (hashcat_ctx_t *hashcat_ctx)
return -1; return -1;
} }
fwrite (rd, sizeof (restore_data_t), 1, fp); hc_fwrite (rd, sizeof (restore_data_t), 1, fp);
for (u32 i = 0; i < rd->argc; i++) for (u32 i = 0; i < rd->argc; i++)
{ {

View File

@ -467,3 +467,15 @@ void hc_string_trim_trailing (char *s)
s[new_len] = 0; s[new_len] = 0;
} }
size_t hc_fread (void *ptr, size_t size, size_t nmemb, FILE *stream)
{
return fread (ptr, size, nmemb, stream);
}
void hc_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream)
{
size_t rc = fwrite (ptr, size, nmemb, stream);
if (rc == 0) rc = 0;
}

View File

@ -10,13 +10,14 @@
#include "rp_kernel_on_cpu.h" #include "rp_kernel_on_cpu.h"
#include "mpsp.h" #include "mpsp.h"
#include "opencl.h" #include "opencl.h"
#include "shared.h"
#include "stdout.h" #include "stdout.h"
static void out_flush (out_t *out) static void out_flush (out_t *out)
{ {
if (out->len == 0) return; if (out->len == 0) return;
fwrite (out->buf, 1, out->len, out->fp); hc_fwrite (out->buf, 1, out->len, out->fp);
out->len = 0; out->len = 0;
} }

View File

@ -688,7 +688,7 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx)
printf ("REJECTED\t%" PRIu64 "\t", hashcat_status->progress_rejected); printf ("REJECTED\t%" PRIu64 "\t", hashcat_status->progress_rejected);
fwrite (EOL, strlen (EOL), 1, stdout); hc_fwrite (EOL, strlen (EOL), 1, stdout);
fflush (stdout); fflush (stdout);

View File

@ -4,6 +4,8 @@
*/ */
#include "common.h" #include "common.h"
#include "types.h"
#include "shared.h"
#include "usage.h" #include "usage.h"
static const char *USAGE_MINI[] = static const char *USAGE_MINI[] =
@ -450,7 +452,7 @@ void usage_mini_print (const char *progname)
{ {
printf (USAGE_MINI[i], progname); printf (USAGE_MINI[i], progname);
fwrite (EOL, strlen (EOL), 1, stdout); hc_fwrite (EOL, strlen (EOL), 1, stdout);
} }
} }
@ -460,6 +462,6 @@ void usage_big_print (const char *progname)
{ {
printf (USAGE_BIG[i], progname); printf (USAGE_BIG[i], progname);
fwrite (EOL, strlen (EOL), 1, stdout); hc_fwrite (EOL, strlen (EOL), 1, stdout);
} }
} }

View File

@ -52,7 +52,7 @@ int load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd)
wl_data->pos = 0; wl_data->pos = 0;
wl_data->cnt = fread (wl_data->buf, 1, wl_data->incr - 1000, fd); wl_data->cnt = hc_fread (wl_data->buf, 1, wl_data->incr - 1000, fd);
wl_data->buf[wl_data->cnt] = 0; wl_data->buf[wl_data->cnt] = 0;