1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-23 16:38:29 +00:00

Do not use NULL for va_* variadic functions

This commit is contained in:
jsteube 2017-02-11 11:51:46 +01:00
parent fdbe6f8281
commit 06c184aeea
2 changed files with 90 additions and 37 deletions

View File

@ -120,7 +120,6 @@ VERSION_TAG := $(shell test -d .git && git describe --tags --dirty=+
## ##
CFLAGS += -pipe -std=c99 -Iinclude/ -Iinclude/lzma_sdk/ -IOpenCL/ CFLAGS += -pipe -std=c99 -Iinclude/ -Iinclude/lzma_sdk/ -IOpenCL/
CFLAGS += -Wno-format-zero-length
ifeq ($(PRODUCTION),0) ifeq ($(PRODUCTION),0)
CFLAGS += -W CFLAGS += -W

View File

@ -68,15 +68,24 @@ static int event_log (const char *fmt, va_list ap, char *s, const size_t sz)
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, ...)
{ {
va_list ap;
va_start (ap, fmt);
event_ctx_t *event_ctx = hashcat_ctx->event_ctx; event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1); if (fmt == NULL)
{
event_ctx->msg_buf[0] = 0;
va_end (ap); event_ctx->msg_len = 0;
}
else
{
va_list ap;
va_start (ap, fmt);
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
va_end (ap);
}
event_ctx->msg_newline = false; event_ctx->msg_newline = false;
@ -87,15 +96,24 @@ size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
size_t event_log_warning_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) size_t event_log_warning_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
{ {
va_list ap;
va_start (ap, fmt);
event_ctx_t *event_ctx = hashcat_ctx->event_ctx; event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1); if (fmt == NULL)
{
event_ctx->msg_buf[0] = 0;
va_end (ap); event_ctx->msg_len = 0;
}
else
{
va_list ap;
va_start (ap, fmt);
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
va_end (ap);
}
event_ctx->msg_newline = false; event_ctx->msg_newline = false;
@ -106,15 +124,24 @@ size_t event_log_warning_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
size_t event_log_error_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) size_t event_log_error_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
{ {
va_list ap;
va_start (ap, fmt);
event_ctx_t *event_ctx = hashcat_ctx->event_ctx; event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1); if (fmt == NULL)
{
event_ctx->msg_buf[0] = 0;
va_end (ap); event_ctx->msg_len = 0;
}
else
{
va_list ap;
va_start (ap, fmt);
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
va_end (ap);
}
event_ctx->msg_newline = false; event_ctx->msg_newline = false;
@ -125,15 +152,24 @@ size_t event_log_error_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
size_t event_log_info (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) size_t event_log_info (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
{ {
va_list ap;
va_start (ap, fmt);
event_ctx_t *event_ctx = hashcat_ctx->event_ctx; event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1); if (fmt == NULL)
{
event_ctx->msg_buf[0] = 0;
va_end (ap); event_ctx->msg_len = 0;
}
else
{
va_list ap;
va_start (ap, fmt);
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
va_end (ap);
}
event_ctx->msg_newline = true; event_ctx->msg_newline = true;
@ -144,15 +180,24 @@ size_t event_log_info (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
size_t event_log_warning (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) size_t event_log_warning (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
{ {
va_list ap;
va_start (ap, fmt);
event_ctx_t *event_ctx = hashcat_ctx->event_ctx; event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1); if (fmt == NULL)
{
event_ctx->msg_buf[0] = 0;
va_end (ap); event_ctx->msg_len = 0;
}
else
{
va_list ap;
va_start (ap, fmt);
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
va_end (ap);
}
event_ctx->msg_newline = true; event_ctx->msg_newline = true;
@ -163,15 +208,24 @@ size_t event_log_warning (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
size_t event_log_error (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) size_t event_log_error (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
{ {
va_list ap;
va_start (ap, fmt);
event_ctx_t *event_ctx = hashcat_ctx->event_ctx; event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1); if (fmt == NULL)
{
event_ctx->msg_buf[0] = 0;
va_end (ap); event_ctx->msg_len = 0;
}
else
{
va_list ap;
va_start (ap, fmt);
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
va_end (ap);
}
event_ctx->msg_newline = true; event_ctx->msg_newline = true;