| version 1.1.1.4, 2013/07/22 10:46:12 | version 1.1.1.6, 2014/06/15 16:12:54 | 
| Line 285  sudo_putenv_nodebug(char *str, bool dupcheck, bool ove | Line 285  sudo_putenv_nodebug(char *str, bool dupcheck, bool ove | 
 | size_t nsize; | size_t nsize; | 
 |  |  | 
 | if (env.env_size > SIZE_MAX - 128) { | if (env.env_size > SIZE_MAX - 128) { | 
| fatalx_nodebug(_("internal error, %s overflow"), | fatalx_nodebug(U_("internal error, %s overflow"), | 
 | "sudo_putenv_nodebug()"); | "sudo_putenv_nodebug()"); | 
 | } | } | 
 | nsize = env.env_size + 128; | nsize = env.env_size + 128; | 
 | if (nsize > SIZE_MAX / sizeof(char *)) { | if (nsize > SIZE_MAX / sizeof(char *)) { | 
| fatalx_nodebug(_("internal error, %s overflow"), | fatalx_nodebug(U_("internal error, %s overflow"), | 
 | "sudo_putenv_nodebug()"); | "sudo_putenv_nodebug()"); | 
 | } | } | 
 | nenvp = realloc(env.envp, nsize * sizeof(char *)); | nenvp = realloc(env.envp, nsize * sizeof(char *)); | 
| Line 364  sudo_putenv(char *str, bool dupcheck, bool overwrite) | Line 364  sudo_putenv(char *str, bool dupcheck, bool overwrite) | 
 | if (rval == -1) { | if (rval == -1) { | 
 | #ifdef ENV_DEBUG | #ifdef ENV_DEBUG | 
 | if (env.envp[env.env_len] != NULL) | if (env.envp[env.env_len] != NULL) | 
| fatalx(_("sudo_putenv: corrupted envp, length mismatch")); | fatalx(U_("sudo_putenv: corrupted envp, length mismatch")); | 
 | #endif | #endif | 
| fatalx(NULL); | fatal(NULL); | 
 | } | } | 
 | debug_return_int(rval); | debug_return_int(rval); | 
 | } | } | 
| Line 392  sudo_setenv2(const char *var, const char *val, bool du | Line 392  sudo_setenv2(const char *var, const char *val, bool du | 
 | strlcat(estring, "=", esize) >= esize || | strlcat(estring, "=", esize) >= esize || | 
 | strlcat(estring, val, esize) >= esize) { | strlcat(estring, val, esize) >= esize) { | 
 |  |  | 
| fatalx(_("internal error, %s overflow"), "sudo_setenv2()"); | fatalx(U_("internal error, %s overflow"), "sudo_setenv2()"); | 
 | } | } | 
 | rval = sudo_putenv(estring, dupcheck, overwrite); | rval = sudo_putenv(estring, dupcheck, overwrite); | 
 | if (rval == -1) | if (rval == -1) | 
| Line 545  sudo_getenv(const char *name) | Line 545  sudo_getenv(const char *name) | 
 | } | } | 
 |  |  | 
 | /* | /* | 
 | * Merge another environment with our private copy. |  | 
 | */ |  | 
 | void |  | 
 | env_merge(char * const envp[], bool overwrite) |  | 
 | { |  | 
 | char * const *ep; |  | 
 | debug_decl(env_merge, SUDO_DEBUG_ENV) |  | 
 |  |  | 
 | for (ep = envp; *ep != NULL; ep++) |  | 
 | sudo_putenv(*ep, true, overwrite); |  | 
 |  |  | 
 | debug_return; |  | 
 | } |  | 
 |  |  | 
 | /* |  | 
 | * Check the env_delete blacklist. | * Check the env_delete blacklist. | 
 | * Returns true if the variable was found, else false. | * Returns true if the variable was found, else false. | 
 | */ | */ | 
| Line 573  matches_env_delete(const char *var) | Line 558  matches_env_delete(const char *var) | 
 | debug_decl(matches_env_delete, SUDO_DEBUG_ENV) | debug_decl(matches_env_delete, SUDO_DEBUG_ENV) | 
 |  |  | 
 | /* Skip anything listed in env_delete. */ | /* Skip anything listed in env_delete. */ | 
| for (cur = def_env_delete; cur; cur = cur->next) { | SLIST_FOREACH(cur, &def_env_delete, entries) { | 
 | len = strlen(cur->value); | len = strlen(cur->value); | 
 | /* Deal with '*' wildcard */ | /* Deal with '*' wildcard */ | 
 | if (cur->value[len - 1] == '*') { | if (cur->value[len - 1] == '*') { | 
| Line 604  matches_env_check(const char *var) | Line 589  matches_env_check(const char *var) | 
 | int keepit = -1; | int keepit = -1; | 
 | debug_decl(matches_env_check, SUDO_DEBUG_ENV) | debug_decl(matches_env_check, SUDO_DEBUG_ENV) | 
 |  |  | 
| for (cur = def_env_check; cur; cur = cur->next) { | SLIST_FOREACH(cur, &def_env_check, entries) { | 
 | len = strlen(cur->value); | len = strlen(cur->value); | 
 | /* Deal with '*' wildcard */ | /* Deal with '*' wildcard */ | 
 | if (cur->value[len - 1] == '*') { | if (cur->value[len - 1] == '*') { | 
| Line 639  matches_env_keep(const char *var) | Line 624  matches_env_keep(const char *var) | 
 | goto done; | goto done; | 
 | } | } | 
 |  |  | 
| for (cur = def_env_keep; cur; cur = cur->next) { | SLIST_FOREACH(cur, &def_env_keep, entries) { | 
 | len = strlen(cur->value); | len = strlen(cur->value); | 
 | /* Deal with '*' wildcard */ | /* Deal with '*' wildcard */ | 
 | if (cur->value[len - 1] == '*') { | if (cur->value[len - 1] == '*') { | 
| Line 695  env_should_keep(const char *var) | Line 680  env_should_keep(const char *var) | 
 | debug_return_bool(keepit == true); | debug_return_bool(keepit == true); | 
 | } | } | 
 |  |  | 
 |  | /* | 
 |  | * Merge another environment with our private copy. | 
 |  | * Only overwrite an existing variable if it is not | 
 |  | * being preserved from the user's environment. | 
 |  | */ | 
 |  | void | 
 |  | env_merge(char * const envp[]) | 
 |  | { | 
 |  | char * const *ep; | 
 |  | debug_decl(env_merge, SUDO_DEBUG_ENV) | 
 |  |  | 
 |  | for (ep = envp; *ep != NULL; ep++) | 
 |  | sudo_putenv(*ep, true, !env_should_keep(*ep)); | 
 |  |  | 
 |  | debug_return; | 
 |  | } | 
 |  |  | 
 | static void | static void | 
 | env_update_didvar(const char *ep, unsigned int *didvar) | env_update_didvar(const char *ep, unsigned int *didvar) | 
 | { | { | 
| Line 1083  init_envtables(void) | Line 1085  init_envtables(void) | 
 | for (p = initial_badenv_table; *p; p++) { | for (p = initial_badenv_table; *p; p++) { | 
 | cur = ecalloc(1, sizeof(struct list_member)); | cur = ecalloc(1, sizeof(struct list_member)); | 
 | cur->value = estrdup(*p); | cur->value = estrdup(*p); | 
| cur->next = def_env_delete; | SLIST_INSERT_HEAD(&def_env_delete, cur, entries); | 
| def_env_delete = cur; |  | 
 | } | } | 
 |  |  | 
 | /* Fill in the "env_check" list. */ | /* Fill in the "env_check" list. */ | 
 | for (p = initial_checkenv_table; *p; p++) { | for (p = initial_checkenv_table; *p; p++) { | 
 | cur = ecalloc(1, sizeof(struct list_member)); | cur = ecalloc(1, sizeof(struct list_member)); | 
 | cur->value = estrdup(*p); | cur->value = estrdup(*p); | 
| cur->next = def_env_check; | SLIST_INSERT_HEAD(&def_env_check, cur, entries); | 
| def_env_check = cur; |  | 
 | } | } | 
 |  |  | 
 | /* Fill in the "env_keep" list. */ | /* Fill in the "env_keep" list. */ | 
 | for (p = initial_keepenv_table; *p; p++) { | for (p = initial_keepenv_table; *p; p++) { | 
 | cur = ecalloc(1, sizeof(struct list_member)); | cur = ecalloc(1, sizeof(struct list_member)); | 
 | cur->value = estrdup(*p); | cur->value = estrdup(*p); | 
| cur->next = def_env_keep; | SLIST_INSERT_HEAD(&def_env_keep, cur, entries); | 
| def_env_keep = cur; |  | 
 | } | } | 
 | } | } | 
 |  |  |