From 1c80c1f4588eff008339b47f490e279493f77bb6 Mon Sep 17 00:00:00 2001 From: Vaibhav Date: Wed, 5 Feb 2020 07:32:40 +0530 Subject: [PATCH] feat(userspace): Add more functions to `banned.h`. These include: * vsprintf() * sprintf() * strcat() * strncat() * strncpy() * swprintf() * vswprintf() This also changes `userspace/falco/logger.cpp` to remove a `sprintf` statement. The statement did not affect the codebase in any form so it was simply removed rather than being substituted. Fixes #1035 Signed-off-by: Vaibhav --- userspace/engine/banned.h | 21 +++++++++++++++++++++ userspace/falco/logger.cpp | 8 ++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/userspace/engine/banned.h b/userspace/engine/banned.h index 21dfdb2c..41690220 100644 --- a/userspace/engine/banned.h +++ b/userspace/engine/banned.h @@ -23,3 +23,24 @@ limitations under the License. #undef strcpy #define strcpy(a, b) BAN(strcpy) + +#undef vsprintf +#define vsprintf(a, b, c) BAN(vsprintf) + +#undef sprintf +#define sprintf(a, b, ...) BAN(sprintf) + +#undef strcat +#define strcat(a, b) BAN(strcat) + +#undef strncat +#define strncat(a, b, c) BAN(strncat) + +#undef strncpy +#define strncpy(a, b, c) BAN(strncpy) + +#undef swprintf +#define swprintf(a, b, c, ...) BAN(swprintf) + +#undef vswprintf +#define vswprintf(a, b, c, d) BAN(vswprintf) diff --git a/userspace/falco/logger.cpp b/userspace/falco/logger.cpp index da4d6cf3..cf023a9b 100644 --- a/userspace/falco/logger.cpp +++ b/userspace/falco/logger.cpp @@ -131,12 +131,8 @@ void falco_logger::log(int priority, const string msg) { char buf[sizeof "YYYY-MM-DDTHH:MM:SS-0000"]; struct tm *gtm = std::gmtime(&result); - if(gtm == NULL || - (strftime(buf, sizeof(buf), "%FT%T%z", gtm) == 0)) - { - sprintf(buf, "N/A"); - } - else + if(gtm != NULL && + (strftime(buf, sizeof(buf), "%FT%T%z", gtm) != 0)) { fprintf(stderr, "%s: %s", buf, msg.c_str()); }