From b08490f0515af98b6c53159ee0f4f9b66f671c09 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Sat, 27 Aug 2022 17:45:52 +0200 Subject: [PATCH] Replace our use of strncpy strncpy will fill the entire buffer with NUL. In this case we have a 128 byte buffer and write "empty" - 5 bytes - into it. So now instead of writing 6 bytes it'll write 128 bytes. Especially wasteful because we already did memset before --- src/common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.cpp b/src/common.cpp index d10344c1e..465f5a89f 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -1683,7 +1683,7 @@ void format_size_safe(char buff[128], unsigned long long sz) { size_t idx = 0; const char *const sz_name[] = {"kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", nullptr}; if (sz < 1) { - strncpy(buff, "empty", buff_size); + strcpy(buff, "empty"); } else if (sz < 1024) { append_ull(buff, sz, &idx, max_len); append_str(buff, "B", &idx, max_len);