diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a1153a63..175bfc791 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Features: Bugfixes: * Fix support of macOS Sonoma (Wallpaper, macOS) * Fix overall memory leaks (macOS) +* Remove trailing `\0` in JSON results (FreeBSD) # 2.5.0 diff --git a/src/common/settings.c b/src/common/settings.c index ae057a292..a01d4e706 100644 --- a/src/common/settings.c +++ b/src/common/settings.c @@ -411,9 +411,8 @@ bool ffSettingsGetFreeBSDKenv(const char* propName, FFstrbuf* result) //https://wiki.ghostbsd.org/index.php/Kenv ffStrbufEnsureFree(result, KENV_MVALLEN); int len = kenv(KENV_GET, propName, result->chars + result->length, KENV_MVALLEN); - if (len <= 0) return false; - result->length += (uint32_t) len; - result->chars[result->length] = '\0'; + if (len <= 1) return false; // number of bytes copied, including NUL terminator + result->length += (uint32_t) len - 1; return true; } #endif