diff --git a/pkg.c b/pkg.c index 4e4d464..2ce3605 100644 --- a/pkg.c +++ b/pkg.c @@ -32,17 +32,19 @@ pkg_get_pkgconfig_path(void) static bool computed = false; static char path[PKG_CONFIG_PATH_SZ]; char *env_path; + size_t len; if (computed) return path; strncpy(path, PKG_DEFAULT_PATH, sizeof path); + len = strlen(PKG_DEFAULT_PATH); env_path = getenv("PKG_CONFIG_PATH"); if (env_path != NULL) { - strncat(path, ":", sizeof path); - strncat(path, env_path, sizeof path); + strncat(path, ":", sizeof path - len - 1); + strncat(path, env_path, sizeof path - len - 2); } return path;