mirror of
https://github.com/hashcat/hashcat.git
synced 2025-01-12 00:31:41 +00:00
Merge pull request #989 from philsmd/master
event_log: do the string termination in event_log () and use MIN ()
This commit is contained in:
commit
6ccb774983
23
src/event.c
23
src/event.c
@ -56,11 +56,18 @@ void event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, cons
|
|||||||
__attribute__ ((format (printf, 1, 0)))
|
__attribute__ ((format (printf, 1, 0)))
|
||||||
static int event_log (const char *fmt, va_list ap, char *s, const size_t sz)
|
static int event_log (const char *fmt, va_list ap, char *s, const size_t sz)
|
||||||
{
|
{
|
||||||
|
size_t length;
|
||||||
|
|
||||||
#if defined (__MINGW32__)
|
#if defined (__MINGW32__)
|
||||||
return __mingw_vsnprintf (s, sz, fmt, ap);
|
length = __mingw_vsnprintf (s, sz, fmt, ap);
|
||||||
#else
|
#else
|
||||||
return vsnprintf (s, sz, fmt, ap);
|
length = vsnprintf (s, sz, fmt, ap);
|
||||||
#endif
|
#endif
|
||||||
|
length = MIN (length, sz);
|
||||||
|
|
||||||
|
s[length] = 0;
|
||||||
|
|
||||||
|
return (int) length;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
|
size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
|
||||||
@ -73,8 +80,6 @@ size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
|
|||||||
|
|
||||||
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
|
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
|
||||||
|
|
||||||
event_ctx->msg_buf[event_ctx->msg_len] = 0;
|
|
||||||
|
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
event_ctx->msg_newline = false;
|
event_ctx->msg_newline = false;
|
||||||
@ -94,8 +99,6 @@ size_t event_log_warning_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
|
|||||||
|
|
||||||
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
|
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
|
||||||
|
|
||||||
event_ctx->msg_buf[event_ctx->msg_len] = 0;
|
|
||||||
|
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
event_ctx->msg_newline = false;
|
event_ctx->msg_newline = false;
|
||||||
@ -115,8 +118,6 @@ size_t event_log_error_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
|
|||||||
|
|
||||||
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
|
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
|
||||||
|
|
||||||
event_ctx->msg_buf[event_ctx->msg_len] = 0;
|
|
||||||
|
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
event_ctx->msg_newline = false;
|
event_ctx->msg_newline = false;
|
||||||
@ -136,8 +137,6 @@ size_t event_log_info (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
|
|||||||
|
|
||||||
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
|
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
|
||||||
|
|
||||||
event_ctx->msg_buf[event_ctx->msg_len] = 0;
|
|
||||||
|
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
event_ctx->msg_newline = true;
|
event_ctx->msg_newline = true;
|
||||||
@ -157,8 +156,6 @@ size_t event_log_warning (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
|
|||||||
|
|
||||||
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
|
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
|
||||||
|
|
||||||
event_ctx->msg_buf[event_ctx->msg_len] = 0;
|
|
||||||
|
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
event_ctx->msg_newline = true;
|
event_ctx->msg_newline = true;
|
||||||
@ -178,8 +175,6 @@ size_t event_log_error (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
|
|||||||
|
|
||||||
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
|
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
|
||||||
|
|
||||||
event_ctx->msg_buf[event_ctx->msg_len] = 0;
|
|
||||||
|
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
event_ctx->msg_newline = true;
|
event_ctx->msg_newline = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user