From c9ac30a8b45f7ad72e5351c6f303b5c5e79168f3 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 2 May 2024 20:14:40 +0200 Subject: [PATCH] (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 --- os/utils.c | 41 +---------------------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/os/utils.c b/os/utils.c index c3d90ac8a..bb14ddbb7 100644 --- a/os/utils.c +++ b/os/utils.c @@ -1363,11 +1363,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 @@ -1401,7 +1396,6 @@ enum BadCode { UnsafeArg, ArgTooLong, UnprintableArg, - EnvTooLong, InternalError }; @@ -1416,7 +1410,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()) @@ -1459,40 +1453,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 } } } @@ -1510,9 +1474,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;