From fbcee9f114bb42810ee824c2bc1bbe4cd4a7a5b2 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 25 Jun 2009 15:58:58 +0000 Subject: [PATCH] strdup the input to putenv to avoid in one case passing a string that is later freed and in the other const strings. --- cmd-string.c | 4 ++-- window.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd-string.c b/cmd-string.c index e05e2799..16f8f5a4 100644 --- a/cmd-string.c +++ b/cmd-string.c @@ -1,4 +1,4 @@ -/* $Id: cmd-string.c,v 1.15 2009-05-15 12:58:56 nicm Exp $ */ +/* $OpenBSD: cmd-string.c,v 1.2 2009/06/05 07:18:37 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -63,7 +63,7 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause) if ((t = strchr(s, ' ')) == NULL && (t = strchr(s, '\t')) == NULL) t = strchr(s, '\0'); if ((u = strchr(s, '=')) != NULL && u < t) { - if (putenv((char *) s) != 0) { + if (putenv(xstrdup(s)) != 0) { xasprintf(cause, "assignment failed: %s", s); return (-1); } diff --git a/window.c b/window.c index 4ebdf04b..d73d5c4e 100644 --- a/window.c +++ b/window.c @@ -1,4 +1,4 @@ -/* $Id: window.c,v 1.78 2009-05-19 13:32:55 tcunha Exp $ */ +/* $OpenBSD: window.c,v 1.2 2009/06/05 07:18:37 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -487,7 +487,7 @@ window_pane_spawn(struct window_pane *wp, if (chdir(wp->cwd) != 0) chdir("/"); for (envq = envp; *envq != NULL; envq++) { - if (putenv((char *) *envq) != 0) + if (putenv(xstrdup(*envq)) != 0) fatal("putenv failed"); } sigreset();