summaryrefslogtreecommitdiff
path: root/sftp-server.c
diff options
context:
space:
mode:
Diffstat (limited to 'sftp-server.c')
-rw-r--r--sftp-server.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sftp-server.c b/sftp-server.c
index eac11d7e6..e11a1b89b 100644
--- a/sftp-server.c
+++ b/sftp-server.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp-server.c,v 1.107 2015/08/20 22:32:42 deraadt Exp $ */ 1/* $OpenBSD: sftp-server.c,v 1.109 2016/02/15 09:47:49 dtucker Exp $ */
2/* 2/*
3 * Copyright (c) 2000-2004 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000-2004 Markus Friedl. All rights reserved.
4 * 4 *
@@ -1513,6 +1513,7 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
1513 extern char *optarg; 1513 extern char *optarg;
1514 extern char *__progname; 1514 extern char *__progname;
1515 1515
1516 ssh_malloc_init(); /* must be called before any mallocs */
1516 __progname = ssh_get_progname(argv[0]); 1517 __progname = ssh_get_progname(argv[0]);
1517 log_init(__progname, log_level, log_facility, log_stderr); 1518 log_init(__progname, log_level, log_facility, log_stderr);
1518 1519
@@ -1598,6 +1599,9 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
1598 fatal("unable to make the process undumpable"); 1599 fatal("unable to make the process undumpable");
1599#endif /* defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE) */ 1600#endif /* defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE) */
1600 1601
1602 /* Drop any fine-grained privileges we don't need */
1603 platform_pledge_sftp_server();
1604
1601 if ((cp = getenv("SSH_CONNECTION")) != NULL) { 1605 if ((cp = getenv("SSH_CONNECTION")) != NULL) {
1602 client_addr = xstrdup(cp); 1606 client_addr = xstrdup(cp);
1603 if ((cp = strchr(client_addr, ' ')) == NULL) { 1607 if ((cp = strchr(client_addr, ' ')) == NULL) {
@@ -1631,9 +1635,8 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
1631 if ((oqueue = sshbuf_new()) == NULL) 1635 if ((oqueue = sshbuf_new()) == NULL)
1632 fatal("%s: sshbuf_new failed", __func__); 1636 fatal("%s: sshbuf_new failed", __func__);
1633 1637
1634 set_size = howmany(max + 1, NFDBITS) * sizeof(fd_mask); 1638 rset = xcalloc(howmany(max + 1, NFDBITS), sizeof(fd_mask));
1635 rset = xmalloc(set_size); 1639 wset = xcalloc(howmany(max + 1, NFDBITS), sizeof(fd_mask));
1636 wset = xmalloc(set_size);
1637 1640
1638 if (homedir != NULL) { 1641 if (homedir != NULL) {
1639 if (chdir(homedir) != 0) { 1642 if (chdir(homedir) != 0) {
@@ -1642,6 +1645,7 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
1642 } 1645 }
1643 } 1646 }
1644 1647
1648 set_size = howmany(max + 1, NFDBITS) * sizeof(fd_mask);
1645 for (;;) { 1649 for (;;) {
1646 memset(rset, 0, set_size); 1650 memset(rset, 0, set_size);
1647 memset(wset, 0, set_size); 1651 memset(wset, 0, set_size);