summaryrefslogtreecommitdiff
path: root/readconf.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2015-10-27 08:54:52 +0000
committerDamien Miller <djm@mindrot.org>2015-10-29 19:07:16 +1100
commita4aef3ed29071719b2af82fdf1ac3c2514f82bc5 (patch)
tree01067499d41be84d147a8ad1d367f5699433bfea /readconf.c
parent63d188175accea83305e89fafa011136ff3d96ad (diff)
upstream commit
fix execv arguments in a way less likely to cause grief for -portable; ok dtucker@ Upstream-ID: 5902bf0ea0371f39f1300698dc3b8e4105fc0fc5
Diffstat (limited to 'readconf.c')
-rw-r--r--readconf.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/readconf.c b/readconf.c
index acfe97e9d..c062433ce 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: readconf.c,v 1.244 2015/10/27 00:49:53 djm Exp $ */ 1/* $OpenBSD: readconf.c,v 1.245 2015/10/27 08:54:52 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -458,7 +458,7 @@ execute_in_shell(const char *cmd)
458 458
459 /* Fork and execute the command. */ 459 /* Fork and execute the command. */
460 if ((pid = fork()) == 0) { 460 if ((pid = fork()) == 0) {
461 char *argv[] = { shell, "-c", xstrdup(cmd), NULL }; 461 char *argv[4];
462 462
463 /* Child. Permanently give up superuser privileges. */ 463 /* Child. Permanently give up superuser privileges. */
464 permanently_drop_suid(original_real_uid); 464 permanently_drop_suid(original_real_uid);
@@ -472,6 +472,11 @@ execute_in_shell(const char *cmd)
472 close(devnull); 472 close(devnull);
473 closefrom(STDERR_FILENO + 1); 473 closefrom(STDERR_FILENO + 1);
474 474
475 argv[0] = shell;
476 argv[1] = "-c";
477 argv[2] = xstrdup(cmd);
478 argv[3] = NULL;
479
475 execv(argv[0], argv); 480 execv(argv[0], argv);
476 error("Unable to execute '%.100s': %s", cmd, strerror(errno)); 481 error("Unable to execute '%.100s': %s", cmd, strerror(errno));
477 /* Die with signal to make this error apparent to parent. */ 482 /* Die with signal to make this error apparent to parent. */