From f27675a0ec3dbd596665cf8f6ff2a836fdb03eae Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 3 Dec 2016 16:04:38 -0800 Subject: [PATCH 1/2] Only apply gnu_printf to MinGW --- include/event.h | 14 ++++++++++---- src/event.c | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/event.h b/include/event.h index 13593dd2f..deda6eafe 100644 --- a/include/event.h +++ b/include/event.h @@ -14,18 +14,24 @@ void event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, cons #define EVENT(id) event_call ((id), hashcat_ctx, NULL, 0) #define EVENT_DATA(id,buf,len) event_call ((id), hashcat_ctx, (buf), (len)) +#if defined (__MINGW32__) +#define EVENT_PRINTF __attribute__ ((format (gnu_printf, 2, 3))) +#else +#define EVENT_PRINTF __attribute__ ((format (printf, 2, 3))) +#endif + __attribute__ ((format (printf, 2, 3))) size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); -__attribute__ ((format (gnu_printf, 2, 3))) +EVENT_PRINTF size_t event_log_warning_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); -__attribute__ ((format (gnu_printf, 2, 3))) +EVENT_PRINTF size_t event_log_error_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); __attribute__ ((format (printf, 2, 3))) size_t event_log_info (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); -__attribute__ ((format (gnu_printf, 2, 3))) +EVENT_PRINTF size_t event_log_warning (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); -__attribute__ ((format (gnu_printf, 2, 3))) +EVENT_PRINTF size_t event_log_error (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); int event_ctx_init (hashcat_ctx_t *hashcat_ctx); diff --git a/src/event.c b/src/event.c index afe90dbe6..82386dc7f 100644 --- a/src/event.c +++ b/src/event.c @@ -53,7 +53,7 @@ void event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, cons } } -__attribute__ ((format (gnu_printf, 1, 0))) +__attribute__ ((format (printf, 1, 0))) static int event_log (const char *fmt, va_list ap, char *s, const size_t sz) { return vsnprintf (s, sz, fmt, ap); From 66d4eea64944ead3c00219affd22772f7d280bbf Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 3 Dec 2016 17:38:27 -0800 Subject: [PATCH 2/2] Fix %m with MinGW --- src/event.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/event.c b/src/event.c index 82386dc7f..1a87af1e5 100644 --- a/src/event.c +++ b/src/event.c @@ -56,7 +56,11 @@ void event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, cons __attribute__ ((format (printf, 1, 0))) static int event_log (const char *fmt, va_list ap, char *s, const size_t sz) { +#if defined (__MINGW32__) + return __mingw_vsnprintf (s, sz, fmt, ap); +#else return vsnprintf (s, sz, fmt, ap); +#endif } size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)