From 30d1257c0dadb88f1c3a8c18f11403490ae0dd80 Mon Sep 17 00:00:00 2001 From: jacob Date: Fri, 15 Jul 2005 11:47:28 +0000 Subject: [PATCH] Patch from Colin Watson: we were sometimes passing stack storage to putenv(), which is Bad (in his case, it caused TERM to end up unset). Use malloc()'d storage instead. git-svn-id: svn://svn.tartarus.org/sgt/putty@6095 cda61777-01e9-0310-a592-d414129be87e --- unix/uxpty.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/unix/uxpty.c b/unix/uxpty.c index b3bda081..96489e1a 100644 --- a/unix/uxpty.c +++ b/unix/uxpty.c @@ -754,15 +754,19 @@ static const char *pty_init(void *frontend, void **backend_handle, Config *cfg, for (i = 3; i < 1024; i++) close(i); { - char term_env_var[10 + sizeof(cfg->termtype)]; - sprintf(term_env_var, "TERM=%s", cfg->termtype); + char *term_env_var = dupprintf("TERM=%s", cfg->termtype); putenv(term_env_var); + /* We mustn't free term_env_var, as putenv links it into the + * environment in place. + */ } #ifndef NOT_X_WINDOWS /* for Mac OS X native compilation */ { - char windowid_env_var[40]; - sprintf(windowid_env_var, "WINDOWID=%ld", windowid); + char *windowid_env_var = dupprintf("WINDOWID=%ld", windowid); putenv(windowid_env_var); + /* We mustn't free windowid_env_var, as putenv links it into the + * environment in place. + */ } #endif { -- 2.11.0