From 994f21fe017fd0f2373399ff7cfb9843bfd303df Mon Sep 17 00:00:00 2001 From: Fl0-0 Date: Fri, 30 Nov 2018 09:03:44 +0100 Subject: [PATCH 1/1] Fix format-truncation warning, missing string.h inclusion and strnlen warning (#723) * Fix format-truncation warning, missing string.h inclusion and strnlen warning * Dynamic string width field --- client/crypto/asn1dump.c | 3 +++ client/ui.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/client/crypto/asn1dump.c b/client/crypto/asn1dump.c index 60799fc8..9570be20 100644 --- a/client/crypto/asn1dump.c +++ b/client/crypto/asn1dump.c @@ -8,11 +8,14 @@ // asn.1 dumping //----------------------------------------------------------------------------- +#define _POSIX_C_SOURCE 200809L // need for strnlen() + #include "asn1dump.h" #include #include #include #include +#include #include #include #include diff --git a/client/ui.c b/client/ui.c index 3a1e42c5..5c9d7424 100644 --- a/client/ui.c +++ b/client/ui.c @@ -99,7 +99,7 @@ void PrintAndLogEx(logLevel_t level, char *fmt, ...) { } PrintAndLog(buffer2); } else { - snprintf(buffer2, sizeof(buffer2), "%s%s", prefix, buffer); + snprintf(buffer2, sizeof(buffer2), "%s%.*s", prefix, MAX_PRINT_BUFFER - 20, buffer); PrintAndLog(buffer2); } } -- 2.39.5