(submit/os-utils) 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>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-05-02 20:14:40 +02:00
parent 5770dd2c22
commit c9ac30a8b4

View File

@ -1363,11 +1363,6 @@ PrivsElevated(void)
#define REMOVE_ENV_LD 1 #define REMOVE_ENV_LD 1
#endif #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) ? */ /* Check args and env only if running setuid (euid == 0 && euid != uid) ? */
#ifndef CHECK_EUID #ifndef CHECK_EUID
#ifndef WIN32 #ifndef WIN32
@ -1401,7 +1396,6 @@ enum BadCode {
UnsafeArg, UnsafeArg,
ArgTooLong, ArgTooLong,
UnprintableArg, UnprintableArg,
EnvTooLong,
InternalError InternalError
}; };
@ -1416,7 +1410,7 @@ CheckUserParameters(int argc, char **argv, char **envp)
{ {
enum BadCode bad = NotBad; enum BadCode bad = NotBad;
int i = 0, j; int i = 0, j;
char *a, *e = NULL; char *a = NULL;
#if CHECK_EUID #if CHECK_EUID
if (PrivsElevated()) if (PrivsElevated())
@ -1459,40 +1453,10 @@ CheckUserParameters(int argc, char **argv, char **envp)
} }
#endif #endif
if (envp[i] && (strlen(envp[i]) > MAX_ENV_LENGTH)) { if (envp[i] && (strlen(envp[i]) > MAX_ENV_LENGTH)) {
#if REMOVE_LONG_ENV
for (j = i; envp[j]; j++) { for (j = i; envp[j]; j++) {
envp[j] = envp[j + 1]; envp[j] = envp[j + 1];
} }
i--; 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
} }
} }
} }
@ -1510,9 +1474,6 @@ CheckUserParameters(int argc, char **argv, char **envp)
ErrorF("Command line argument number %d contains unprintable" ErrorF("Command line argument number %d contains unprintable"
" characters\n", i); " characters\n", i);
break; break;
case EnvTooLong:
ErrorF("Environment variable `%s' is too long\n", e);
break;
case InternalError: case InternalError:
ErrorF("Internal Error\n"); ErrorF("Internal Error\n");
break; break;