mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-16 06:54:03 +00:00
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
This commit is contained in:
parent
07b2f1054b
commit
b08490f051
1 changed files with 1 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue