From 97b58b16afc42f1e7e5f0ed1410e3e910d55ffe8 Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 25 Oct 2016 12:25:53 +0200 Subject: [PATCH] Fix some EOL handling --- include/common.h | 53 +++++++++++++++++++++++------------------------- include/types.h | 5 ++--- include/usage.h | 1 + src/cpt.c | 4 ++-- src/hashes.c | 2 +- src/outfile.c | 2 +- src/status.c | 6 +++--- src/terminal.c | 2 +- src/usage.c | 6 ++++-- 9 files changed, 40 insertions(+), 41 deletions(-) diff --git a/include/common.h b/include/common.h index cfe5c2d15..9bb7923b8 100644 --- a/include/common.h +++ b/include/common.h @@ -24,38 +24,13 @@ #define _GNU_SOURCE #define _FILE_OFFSET_BITS 64 -// don't try to simply change this, it will not work -#define PW_MIN 0 -#define PW_MAX 54 -#define PW_MAX1 (PW_MAX + 1) - -#define PW_DICTMAX 31 -#define PW_DICTMAX1 (PW_DICTMAX + 1) - -#define EXEC_CACHE 128 - -#define SPEED_CACHE 128 -#define SPEED_MAXAGE 4096 - -// general buffer size in case the size is unknown at compile-time -#define HCBUFSIZ_TINY 0x100 -#define HCBUFSIZ_LARGE 0x50000 - -#define BLOCK_SIZE 64 - -#define EXPECTED_ITERATIONS 10000 +#define NOMINMAX 1 #define MIN(a,b) (((a) < (b)) ? (a) : (b)) #define MAX(a,b) (((a) > (b)) ? (a) : (b)) -#define DEVICES_MAX 128 - -#define MAX_CUT_TRIES 4 - #define CEIL(a) ((a - (int) (a)) > 0 ? a + 1 : a) -#define NOMINMAX 1 - #if defined (__APPLE__) #define __stdcall #endif @@ -81,12 +56,34 @@ but this is nededed for VS compiler which doesn't have inline keyword but has __ #endif #endif +#define MAYBE_UNUSED __attribute__((unused)) + +// config section +// do not try to simply change this, it will not work + +#define PW_MIN 0 +#define PW_MAX 54 +#define PW_MAX1 (PW_MAX + 1) +#define PW_DICTMAX 31 +#define PW_DICTMAX1 (PW_DICTMAX + 1) + +#define HCBUFSIZ_TINY 0x100 +#define HCBUFSIZ_LARGE 0x50000 + +#define CPT_CACHE 0x20000 +#define PARAMCNT 64 +#define DEVICES_MAX 128 +#define EXEC_CACHE 128 +#define SPEED_CACHE 128 +#define SPEED_MAXAGE 4096 +#define BLOCK_SIZE 64 +#define EXPECTED_ITERATIONS 10000 +#define MAX_CUT_TRIES 4 + #if defined (_WIN) #define EOL "\r\n" #else #define EOL "\n" #endif -#define MAYBE_UNUSED __attribute__((unused)) - #endif // _COMMON_H diff --git a/include/types.h b/include/types.h index 56694920c..1e827a610 100644 --- a/include/types.h +++ b/include/types.h @@ -6,6 +6,8 @@ #ifndef _TYPES_H #define _TYPES_H +#include "common.h" + #include #include #include @@ -14,9 +16,6 @@ #include #include -#define CPT_BUF 0x20000 -#define PARAMCNT 64 - #if defined (_WIN) #include #if defined (_BASETSD_H) diff --git a/include/usage.h b/include/usage.h index 6a1b88543..1280ce190 100644 --- a/include/usage.h +++ b/include/usage.h @@ -7,6 +7,7 @@ #define _USAGE_H #include +#include void usage_mini_print (const char *progname); void usage_big_print (const char *progname); diff --git a/src/cpt.c b/src/cpt.c index 9386b5d64..a64b04792 100644 --- a/src/cpt.c +++ b/src/cpt.c @@ -25,7 +25,7 @@ int cpt_ctx_init (hashcat_ctx_t *hashcat_ctx) cpt_ctx->enabled = true; - cpt_ctx->cpt_buf = (cpt_t *) hccalloc (hashcat_ctx, CPT_BUF, sizeof (cpt_t)); VERIFY_PTR (cpt_ctx->cpt_buf); + cpt_ctx->cpt_buf = (cpt_t *) hccalloc (hashcat_ctx, CPT_CACHE, sizeof (cpt_t)); VERIFY_PTR (cpt_ctx->cpt_buf); cpt_ctx->cpt_total = 0; cpt_ctx->cpt_pos = 0; @@ -51,7 +51,7 @@ void cpt_ctx_reset (hashcat_ctx_t *hashcat_ctx) if (cpt_ctx->enabled == false) return; - memset (cpt_ctx->cpt_buf, 0, CPT_BUF * sizeof (cpt_t)); + memset (cpt_ctx->cpt_buf, 0, CPT_CACHE * sizeof (cpt_t)); cpt_ctx->cpt_total = 0; cpt_ctx->cpt_pos = 0; diff --git a/src/hashes.c b/src/hashes.c index a07614dcb..836db5d6f 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -380,7 +380,7 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, cpt_ctx->cpt_total += cpt_cracked; - if (cpt_ctx->cpt_pos == CPT_BUF) cpt_ctx->cpt_pos = 0; + if (cpt_ctx->cpt_pos == CPT_CACHE) cpt_ctx->cpt_pos = 0; hc_thread_mutex_unlock (status_ctx->mux_display); } diff --git a/src/outfile.c b/src/outfile.c index 4a8549bed..9b036cdd7 100644 --- a/src/outfile.c +++ b/src/outfile.c @@ -421,7 +421,7 @@ int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsign if (outfile_ctx->fp) { - fprintf (outfile_ctx->fp, "%s" EOL, tmp_buf); + fwrite (EOL, strlen (EOL), 1, outfile_ctx->fp); } return tmp_len; diff --git a/src/status.c b/src/status.c index 273b379e1..2ff7032c2 100644 --- a/src/status.c +++ b/src/status.c @@ -1253,7 +1253,7 @@ int status_get_cpt_cur_min (const hashcat_ctx_t *hashcat_ctx) int cpt_cur_min = 0; - for (int i = 0; i < CPT_BUF; i++) + for (int i = 0; i < CPT_CACHE; i++) { const u32 cracked = cpt_ctx->cpt_buf[i].cracked; const time_t timestamp = cpt_ctx->cpt_buf[i].timestamp; @@ -1278,7 +1278,7 @@ int status_get_cpt_cur_hour (const hashcat_ctx_t *hashcat_ctx) int cpt_cur_hour = 0; - for (int i = 0; i < CPT_BUF; i++) + for (int i = 0; i < CPT_CACHE; i++) { const u32 cracked = cpt_ctx->cpt_buf[i].cracked; const time_t timestamp = cpt_ctx->cpt_buf[i].timestamp; @@ -1303,7 +1303,7 @@ int status_get_cpt_cur_day (const hashcat_ctx_t *hashcat_ctx) int cpt_cur_day = 0; - for (int i = 0; i < CPT_BUF; i++) + for (int i = 0; i < CPT_CACHE; i++) { const u32 cracked = cpt_ctx->cpt_buf[i].cracked; const time_t timestamp = cpt_ctx->cpt_buf[i].timestamp; diff --git a/src/terminal.c b/src/terminal.c index 309fc809a..7ee5d77ef 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -523,7 +523,7 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) } } - printf (EOL); + fwrite (EOL, strlen (EOL), 1, stdout); fflush (stdout); diff --git a/src/usage.c b/src/usage.c index 5df411326..ce159c96b 100644 --- a/src/usage.c +++ b/src/usage.c @@ -414,7 +414,8 @@ void usage_mini_print (const char *progname) for (int i = 0; USAGE_MINI[i] != NULL; i++) { printf (USAGE_MINI[i], progname); - printf (EOL); + + fwrite (EOL, strlen (EOL), 1, stdout); } } @@ -423,6 +424,7 @@ void usage_big_print (const char *progname) for (int i = 0; USAGE_BIG[i] != NULL; i++) { printf (USAGE_BIG[i], progname); - printf (EOL); + + fwrite (EOL, strlen (EOL), 1, stdout); } }