os: utils: drop REMOVE_LONG_ENV conditional

This always had been enabled since it's incarnation back two decades ago,
so it doesn't seem to be necessary keeping that conditional any longer.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1518>
(cherry picked from commit b5d897d126)
This commit is contained in:
Enrico Weigelt, metux IT consult
2024-05-02 20:14:40 +02:00
committed by Alan Coopersmith
parent 1ce6028cb0
commit b7587614b9

View File

@@ -1719,11 +1719,6 @@ PrivsElevated(void)
#define REMOVE_ENV_LD 1
#endif
/* Remove long environment variables? */
#ifndef REMOVE_LONG_ENV
#define REMOVE_LONG_ENV 1
#endif
/* Check args and env only if running setuid (euid == 0 && euid != uid) ? */
#ifndef CHECK_EUID
#ifndef WIN32
@@ -1757,7 +1752,6 @@ enum BadCode {
UnsafeArg,
ArgTooLong,
UnprintableArg,
EnvTooLong,
InternalError
};
@@ -1774,7 +1768,7 @@ CheckUserParameters(int argc, char **argv, char **envp)
{
enum BadCode bad = NotBad;
int i = 0, j;
char *a, *e = NULL;
char *a = NULL;
#if CHECK_EUID
if (PrivsElevated())
@@ -1817,40 +1811,10 @@ CheckUserParameters(int argc, char **argv, char **envp)
}
#endif
if (envp[i] && (strlen(envp[i]) > MAX_ENV_LENGTH)) {
#if REMOVE_LONG_ENV
for (j = i; envp[j]; j++) {
envp[j] = envp[j + 1];
}
i--;
#else
char *eq;
int len;
eq = strchr(envp[i], '=');
if (!eq)
continue;
len = eq - envp[i];
e = strndup(envp[i], len);
if (!e) {
bad = InternalError;
break;
}
if (len >= 4 &&
(strcmp(e + len - 4, "PATH") == 0 ||
strcmp(e, "TERMCAP") == 0)) {
if (strlen(envp[i]) > MAX_ENV_PATH_LENGTH) {
bad = EnvTooLong;
break;
}
else {
free(e);
}
}
else {
bad = EnvTooLong;
break;
}
#endif
}
}
}
@@ -1868,9 +1832,6 @@ CheckUserParameters(int argc, char **argv, char **envp)
ErrorF("Command line argument number %d contains unprintable"
" characters\n", i);
break;
case EnvTooLong:
ErrorF("Environment variable `%s' is too long\n", e);
break;
case InternalError:
ErrorF("Internal Error\n");
break;