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>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-05-02 20:14:40 +02:00 committed by Marge Bot
parent 6c6944be14
commit b5d897d126

View File

@ -1421,11 +1421,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
@ -1459,7 +1454,6 @@ enum BadCode {
UnsafeArg,
ArgTooLong,
UnprintableArg,
EnvTooLong,
InternalError
};
@ -1474,7 +1468,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())
@ -1517,40 +1511,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
}
}
}
@ -1568,9 +1532,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;