summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorotto@openbsd.org <otto@openbsd.org>2019-06-06 05:13:13 +0000
committerDarren Tucker <dtucker@dtucker.net>2019-06-08 00:25:42 +1000
commit0323d9b619d512f80c57575b810a05791891f657 (patch)
tree6bde14513c6fe9ff37d069325ee6baac112b6b60
parentc586d2d3129265ea64b12960c379d634bccb6535 (diff)
upstream: Replace calls to ssh_malloc_init() by a static init of
malloc_options. Prepares for changes in the way malloc is initialized. ok guenther@ dtucker@ OpenBSD-Commit-ID: 154f4e3e174f614b09f792d4d06575e08de58a6b
-rw-r--r--sftp-server-main.c3
-rw-r--r--sftp-server.c3
-rw-r--r--sftp.c3
-rw-r--r--ssh-add.c3
-rw-r--r--ssh-agent.c3
-rw-r--r--ssh-keygen.c3
-rw-r--r--ssh-keyscan.c3
-rw-r--r--ssh-keysign.c3
-rw-r--r--ssh-pkcs11-helper.c3
-rw-r--r--ssh.c3
-rw-r--r--sshd.c4
-rw-r--r--xmalloc.c10
12 files changed, 13 insertions, 31 deletions
diff --git a/sftp-server-main.c b/sftp-server-main.c
index 6230d897d..06566d36e 100644
--- a/sftp-server-main.c
+++ b/sftp-server-main.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp-server-main.c,v 1.5 2016/02/15 09:47:49 dtucker Exp $ */ 1/* $OpenBSD: sftp-server-main.c,v 1.6 2019/06/06 05:13:13 otto Exp $ */
2/* 2/*
3 * Copyright (c) 2008 Markus Friedl. All rights reserved. 3 * Copyright (c) 2008 Markus Friedl. All rights reserved.
4 * 4 *
@@ -39,7 +39,6 @@ main(int argc, char **argv)
39{ 39{
40 struct passwd *user_pw; 40 struct passwd *user_pw;
41 41
42 ssh_malloc_init(); /* must be called before any mallocs */
43 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ 42 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
44 sanitise_stdfd(); 43 sanitise_stdfd();
45 44
diff --git a/sftp-server.c b/sftp-server.c
index 19a132bd9..ee6013e3f 100644
--- a/sftp-server.c
+++ b/sftp-server.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp-server.c,v 1.114 2019/01/16 23:22:10 djm Exp $ */ 1/* $OpenBSD: sftp-server.c,v 1.115 2019/06/06 05:13:13 otto 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 *
@@ -1574,7 +1574,6 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
1574 extern char *optarg; 1574 extern char *optarg;
1575 extern char *__progname; 1575 extern char *__progname;
1576 1576
1577 ssh_malloc_init(); /* must be called before any mallocs */
1578 __progname = ssh_get_progname(argv[0]); 1577 __progname = ssh_get_progname(argv[0]);
1579 log_init(__progname, log_level, log_facility, log_stderr); 1578 log_init(__progname, log_level, log_facility, log_stderr);
1580 1579
diff --git a/sftp.c b/sftp.c
index 44aa19d96..04881c83f 100644
--- a/sftp.c
+++ b/sftp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp.c,v 1.190 2019/01/21 22:50:42 tb Exp $ */ 1/* $OpenBSD: sftp.c,v 1.191 2019/06/06 05:13:13 otto Exp $ */
2/* 2/*
3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> 3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
4 * 4 *
@@ -2388,7 +2388,6 @@ main(int argc, char **argv)
2388 size_t num_requests = DEFAULT_NUM_REQUESTS; 2388 size_t num_requests = DEFAULT_NUM_REQUESTS;
2389 long long limit_kbps = 0; 2389 long long limit_kbps = 0;
2390 2390
2391 ssh_malloc_init(); /* must be called before any mallocs */
2392 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ 2391 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
2393 sanitise_stdfd(); 2392 sanitise_stdfd();
2394 msetlocale(); 2393 msetlocale();
diff --git a/ssh-add.c b/ssh-add.c
index ac9c808dd..9cf298918 100644
--- a/ssh-add.c
+++ b/ssh-add.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-add.c,v 1.138 2019/01/21 12:53:35 djm Exp $ */ 1/* $OpenBSD: ssh-add.c,v 1.139 2019/06/06 05:13:13 otto 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
@@ -575,7 +575,6 @@ main(int argc, char **argv)
575 SyslogFacility log_facility = SYSLOG_FACILITY_AUTH; 575 SyslogFacility log_facility = SYSLOG_FACILITY_AUTH;
576 LogLevel log_level = SYSLOG_LEVEL_INFO; 576 LogLevel log_level = SYSLOG_LEVEL_INFO;
577 577
578 ssh_malloc_init(); /* must be called before any mallocs */
579 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ 578 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
580 sanitise_stdfd(); 579 sanitise_stdfd();
581 580
diff --git a/ssh-agent.c b/ssh-agent.c
index d06ecfd98..034f31387 100644
--- a/ssh-agent.c
+++ b/ssh-agent.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-agent.c,v 1.233 2019/01/22 22:58:50 djm Exp $ */ 1/* $OpenBSD: ssh-agent.c,v 1.234 2019/06/06 05:13:13 otto 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
@@ -1096,7 +1096,6 @@ main(int ac, char **av)
1096 size_t npfd = 0; 1096 size_t npfd = 0;
1097 u_int maxfds; 1097 u_int maxfds;
1098 1098
1099 ssh_malloc_init(); /* must be called before any mallocs */
1100 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ 1099 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
1101 sanitise_stdfd(); 1100 sanitise_stdfd();
1102 1101
diff --git a/ssh-keygen.c b/ssh-keygen.c
index db371090d..010667157 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-keygen.c,v 1.330 2019/05/29 08:30:26 lum Exp $ */ 1/* $OpenBSD: ssh-keygen.c,v 1.331 2019/06/06 05:13:13 otto Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -2457,7 +2457,6 @@ main(int argc, char **argv)
2457 extern int optind; 2457 extern int optind;
2458 extern char *optarg; 2458 extern char *optarg;
2459 2459
2460 ssh_malloc_init(); /* must be called before any mallocs */
2461 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ 2460 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
2462 sanitise_stdfd(); 2461 sanitise_stdfd();
2463 2462
diff --git a/ssh-keyscan.c b/ssh-keyscan.c
index 2ed041559..7b7c0f320 100644
--- a/ssh-keyscan.c
+++ b/ssh-keyscan.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-keyscan.c,v 1.126 2019/01/26 22:35:01 djm Exp $ */ 1/* $OpenBSD: ssh-keyscan.c,v 1.127 2019/06/06 05:13:13 otto Exp $ */
2/* 2/*
3 * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>. 3 * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>.
4 * 4 *
@@ -656,7 +656,6 @@ main(int argc, char **argv)
656 extern int optind; 656 extern int optind;
657 extern char *optarg; 657 extern char *optarg;
658 658
659 ssh_malloc_init(); /* must be called before any mallocs */
660 __progname = ssh_get_progname(argv[0]); 659 __progname = ssh_get_progname(argv[0]);
661 seed_rng(); 660 seed_rng();
662 TAILQ_INIT(&tq); 661 TAILQ_INIT(&tq);
diff --git a/ssh-keysign.c b/ssh-keysign.c
index 601f6ca72..9ebc67860 100644
--- a/ssh-keysign.c
+++ b/ssh-keysign.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-keysign.c,v 1.56 2018/11/23 05:08:07 djm Exp $ */ 1/* $OpenBSD: ssh-keysign.c,v 1.57 2019/06/06 05:13:13 otto Exp $ */
2/* 2/*
3 * Copyright (c) 2002 Markus Friedl. All rights reserved. 3 * Copyright (c) 2002 Markus Friedl. All rights reserved.
4 * 4 *
@@ -173,7 +173,6 @@ main(int argc, char **argv)
173 char *host, *fp; 173 char *host, *fp;
174 size_t slen, dlen; 174 size_t slen, dlen;
175 175
176 ssh_malloc_init(); /* must be called before any mallocs */
177 if (pledge("stdio rpath getpw dns id", NULL) != 0) 176 if (pledge("stdio rpath getpw dns id", NULL) != 0)
178 fatal("%s: pledge: %s", __progname, strerror(errno)); 177 fatal("%s: pledge: %s", __progname, strerror(errno));
179 178
diff --git a/ssh-pkcs11-helper.c b/ssh-pkcs11-helper.c
index cb873e20b..cd79db2ae 100644
--- a/ssh-pkcs11-helper.c
+++ b/ssh-pkcs11-helper.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-pkcs11-helper.c,v 1.18 2019/05/16 08:47:27 dtucker Exp $ */ 1/* $OpenBSD: ssh-pkcs11-helper.c,v 1.19 2019/06/06 05:13:13 otto Exp $ */
2/* 2/*
3 * Copyright (c) 2010 Markus Friedl. All rights reserved. 3 * Copyright (c) 2010 Markus Friedl. All rights reserved.
4 * 4 *
@@ -322,7 +322,6 @@ main(int argc, char **argv)
322 extern char *__progname; 322 extern char *__progname;
323 struct pollfd pfd[2]; 323 struct pollfd pfd[2];
324 324
325 ssh_malloc_init(); /* must be called before any mallocs */
326 __progname = ssh_get_progname(argv[0]); 325 __progname = ssh_get_progname(argv[0]);
327 seed_rng(); 326 seed_rng();
328 TAILQ_INIT(&pkcs11_keylist); 327 TAILQ_INIT(&pkcs11_keylist);
diff --git a/ssh.c b/ssh.c
index f46a3b262..d8d614111 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh.c,v 1.501 2019/04/23 11:56:41 dtucker Exp $ */ 1/* $OpenBSD: ssh.c,v 1.502 2019/06/06 05:13:13 otto 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
@@ -596,7 +596,6 @@ main(int ac, char **av)
596 struct ssh_digest_ctx *md; 596 struct ssh_digest_ctx *md;
597 u_char conn_hash[SSH_DIGEST_MAX_LENGTH]; 597 u_char conn_hash[SSH_DIGEST_MAX_LENGTH];
598 598
599 ssh_malloc_init(); /* must be called before any mallocs */
600 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ 599 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
601 sanitise_stdfd(); 600 sanitise_stdfd();
602 601
diff --git a/sshd.c b/sshd.c
index 1fcde502b..be23fbc80 100644
--- a/sshd.c
+++ b/sshd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshd.c,v 1.534 2019/04/18 18:56:16 dtucker Exp $ */ 1/* $OpenBSD: sshd.c,v 1.535 2019/06/06 05:13:13 otto 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
@@ -1433,8 +1433,6 @@ main(int ac, char **av)
1433 Authctxt *authctxt; 1433 Authctxt *authctxt;
1434 struct connection_info *connection_info = NULL; 1434 struct connection_info *connection_info = NULL;
1435 1435
1436 ssh_malloc_init(); /* must be called before any mallocs */
1437
1438#ifdef HAVE_SECUREWARE 1436#ifdef HAVE_SECUREWARE
1439 (void)set_auth_parameters(ac, av); 1437 (void)set_auth_parameters(ac, av);
1440#endif 1438#endif
diff --git a/xmalloc.c b/xmalloc.c
index 5cc0310a4..be26510cf 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: xmalloc.c,v 1.34 2017/05/31 09:15:42 deraadt Exp $ */ 1/* $OpenBSD: xmalloc.c,v 1.35 2019/06/06 05:13:13 otto 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
@@ -26,15 +26,9 @@
26#include "xmalloc.h" 26#include "xmalloc.h"
27#include "log.h" 27#include "log.h"
28 28
29void
30ssh_malloc_init(void)
31{
32#if defined(__OpenBSD__) 29#if defined(__OpenBSD__)
33 extern char *malloc_options; 30+char *malloc_options = "S";
34
35 malloc_options = "S";
36#endif /* __OpenBSD__ */ 31#endif /* __OpenBSD__ */
37}
38 32
39void * 33void *
40xmalloc(size_t size) 34xmalloc(size_t size)