if (flags & REPLACE_ENV_USE_ENVIRONMENT) {
const char *t;
+ /* Safety check that the name is not overly long, before we do a stack allocation */
+ if (k > (size_t) sysconf(_SC_ARG_MAX) - 2)
+ return NULL;
+
t = strndupa_safe(name, k);
return getenv(t);
};