From 4d28fa78abce2890e136281950633fae2066cc29 Mon Sep 17 00:00:00 2001 From: "deraadt@openbsd.org" Date: Fri, 28 Jun 2019 13:35:04 +0000 Subject: upstream: When system calls indicate an error they return -1, not some arbitrary value < 0. errno is only updated in this case. Change all (most?) callers of syscalls to follow this better, and let's see if this strictness helps us in the future. OpenBSD-Commit-ID: 48081f00db7518e3b712a49dca06efc2a5428075 --- auth.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'auth.c') diff --git a/auth.c b/auth.c index 8696f258e..b41d39cdc 100644 --- a/auth.c +++ b/auth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth.c,v 1.138 2019/01/19 21:41:18 djm Exp $ */ +/* $OpenBSD: auth.c,v 1.139 2019/06/28 13:35:04 deraadt Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -167,7 +167,7 @@ allowed_user(struct ssh *ssh, struct passwd * pw) char *shell = xstrdup((pw->pw_shell[0] == '\0') ? _PATH_BSHELL : pw->pw_shell); /* empty = /bin/sh */ - if (stat(shell, &st) != 0) { + if (stat(shell, &st) == -1) { logit("User %.100s not allowed because shell %.100s " "does not exist", pw->pw_name, shell); free(shell); @@ -517,7 +517,7 @@ auth_openfile(const char *file, struct passwd *pw, int strict_modes, return NULL; } - if (fstat(fd, &st) < 0) { + if (fstat(fd, &st) == -1) { close(fd); return NULL; } @@ -746,7 +746,7 @@ remote_hostname(struct ssh *ssh) fromlen = sizeof(from); memset(&from, 0, sizeof(from)); if (getpeername(ssh_packet_get_connection_in(ssh), - (struct sockaddr *)&from, &fromlen) < 0) { + (struct sockaddr *)&from, &fromlen) == -1) { debug("getpeername failed: %.100s", strerror(errno)); return strdup(ntop); } @@ -884,7 +884,7 @@ subprocess(const char *tag, struct passwd *pw, const char *command, return 0; } temporarily_use_uid(pw); - if (stat(av[0], &st) < 0) { + if (stat(av[0], &st) == -1) { error("Could not stat %s \"%s\": %s", tag, av[0], strerror(errno)); restore_uid(); @@ -896,7 +896,7 @@ subprocess(const char *tag, struct passwd *pw, const char *command, return 0; } /* Prepare to keep the child's stdout if requested */ - if (pipe(p) != 0) { + if (pipe(p) == -1) { error("%s: pipe: %s", tag, strerror(errno)); restore_uid(); return 0; @@ -946,12 +946,12 @@ subprocess(const char *tag, struct passwd *pw, const char *command, closefrom(STDERR_FILENO + 1); /* Don't use permanently_set_uid() here to avoid fatal() */ - if (setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) != 0) { + if (setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) == -1) { error("%s: setresgid %u: %s", tag, (u_int)pw->pw_gid, strerror(errno)); _exit(1); } - if (setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) != 0) { + if (setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) == -1) { error("%s: setresuid %u: %s", tag, (u_int)pw->pw_uid, strerror(errno)); _exit(1); -- cgit v1.2.3 From be02d7cbde3d211ec2ed2320a1f7d86b2339d758 Mon Sep 17 00:00:00 2001 From: "djm@openbsd.org" Date: Fri, 6 Sep 2019 04:53:27 +0000 Subject: upstream: lots of things were relying on libcrypto headers to transitively include various system headers (mostly stdlib.h); include them explicitly OpenBSD-Commit-ID: 5b522f4f2d844f78bf1cc4f3f4cc392e177b2080 --- auth-options.c | 3 ++- auth.c | 3 ++- auth2-chall.c | 3 ++- auth2-hostbased.c | 3 ++- auth2-kbdint.c | 5 ++++- auth2-passwd.c | 3 ++- auth2-pubkey.c | 3 ++- auth2.c | 3 ++- hmac.c | 3 ++- krl.c | 3 ++- log.h | 4 +++- loginrec.c | 1 + mac.c | 3 ++- ssh-keygen.c | 3 ++- ssh-keysign.c | 3 ++- ssh-pkcs11-helper.c | 3 ++- ssh_api.c | 7 ++++++- sshbuf-getput-basic.c | 3 ++- 18 files changed, 42 insertions(+), 17 deletions(-) (limited to 'auth.c') diff --git a/auth-options.c b/auth-options.c index ac362e271..6fb59dc7e 100644 --- a/auth-options.c +++ b/auth-options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth-options.c,v 1.87 2019/09/03 08:32:11 djm Exp $ */ +/* $OpenBSD: auth-options.c,v 1.88 2019/09/06 04:53:27 djm Exp $ */ /* * Copyright (c) 2018 Damien Miller * @@ -19,6 +19,7 @@ #include +#include #include #include #include diff --git a/auth.c b/auth.c index b41d39cdc..61fb1feb3 100644 --- a/auth.c +++ b/auth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth.c,v 1.139 2019/06/28 13:35:04 deraadt Exp $ */ +/* $OpenBSD: auth.c,v 1.140 2019/09/06 04:53:27 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -32,6 +32,7 @@ #include +#include #include #include #ifdef HAVE_PATHS_H diff --git a/auth2-chall.c b/auth2-chall.c index 2d5cff448..671f2f05f 100644 --- a/auth2-chall.c +++ b/auth2-chall.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth2-chall.c,v 1.50 2018/07/11 18:55:11 markus Exp $ */ +/* $OpenBSD: auth2-chall.c,v 1.51 2019/09/06 04:53:27 djm Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * Copyright (c) 2001 Per Allansson. All rights reserved. @@ -28,6 +28,7 @@ #include +#include #include #include #include diff --git a/auth2-hostbased.c b/auth2-hostbased.c index 0c40fad4e..d46047084 100644 --- a/auth2-hostbased.c +++ b/auth2-hostbased.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth2-hostbased.c,v 1.40 2019/01/19 21:43:56 djm Exp $ */ +/* $OpenBSD: auth2-hostbased.c,v 1.41 2019/09/06 04:53:27 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -27,6 +27,7 @@ #include +#include #include #include #include diff --git a/auth2-kbdint.c b/auth2-kbdint.c index a813b8f56..f88ef2c39 100644 --- a/auth2-kbdint.c +++ b/auth2-kbdint.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth2-kbdint.c,v 1.9 2018/07/09 21:35:50 markus Exp $ */ +/* $OpenBSD: auth2-kbdint.c,v 1.10 2019/09/06 04:53:27 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -29,6 +29,9 @@ #include +#include +#include + #include "xmalloc.h" #include "packet.h" #include "hostfile.h" diff --git a/auth2-passwd.c b/auth2-passwd.c index f696abc21..6601e8664 100644 --- a/auth2-passwd.c +++ b/auth2-passwd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth2-passwd.c,v 1.16 2018/07/09 21:35:50 markus Exp $ */ +/* $OpenBSD: auth2-passwd.c,v 1.17 2019/09/06 04:53:27 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -27,6 +27,7 @@ #include +#include #include #include #include diff --git a/auth2-pubkey.c b/auth2-pubkey.c index d567f527c..df12c2c60 100644 --- a/auth2-pubkey.c +++ b/auth2-pubkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth2-pubkey.c,v 1.93 2019/09/03 08:30:47 djm Exp $ */ +/* $OpenBSD: auth2-pubkey.c,v 1.94 2019/09/06 04:53:27 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -28,6 +28,7 @@ #include #include +#include #include #include #ifdef HAVE_PATHS_H diff --git a/auth2.c b/auth2.c index 9b08757ae..2143ff5de 100644 --- a/auth2.c +++ b/auth2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth2.c,v 1.156 2019/06/28 05:44:09 deraadt Exp $ */ +/* $OpenBSD: auth2.c,v 1.157 2019/09/06 04:53:27 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -37,6 +37,7 @@ #include #include +#include "stdlib.h" #include "atomicio.h" #include "xmalloc.h" #include "ssh2.h" diff --git a/hmac.c b/hmac.c index e90b294fb..a79e8569c 100644 --- a/hmac.c +++ b/hmac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hmac.c,v 1.12 2015/03/24 20:03:44 markus Exp $ */ +/* $OpenBSD: hmac.c,v 1.13 2019/09/06 04:53:27 djm Exp $ */ /* * Copyright (c) 2014 Markus Friedl. All rights reserved. * @@ -21,6 +21,7 @@ #include #include +#include #include "sshbuf.h" #include "digest.h" diff --git a/krl.c b/krl.c index f36ba68ac..10a8bcc87 100644 --- a/krl.c +++ b/krl.c @@ -14,7 +14,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $OpenBSD: krl.c,v 1.43 2019/06/21 04:21:04 djm Exp $ */ +/* $OpenBSD: krl.c,v 1.44 2019/09/06 04:53:27 djm Exp $ */ #include "includes.h" @@ -29,6 +29,7 @@ #include #include #include +#include #include "sshbuf.h" #include "ssherr.h" diff --git a/log.h b/log.h index ef7bea7e1..78cda287d 100644 --- a/log.h +++ b/log.h @@ -1,4 +1,4 @@ -/* $OpenBSD: log.h,v 1.23 2018/07/27 12:03:17 markus Exp $ */ +/* $OpenBSD: log.h,v 1.24 2019/09/06 04:53:27 djm Exp $ */ /* * Author: Tatu Ylonen @@ -15,6 +15,8 @@ #ifndef SSH_LOG_H #define SSH_LOG_H +#include /* va_list */ + /* Supported syslog facilities and levels. */ typedef enum { SYSLOG_FACILITY_DAEMON, diff --git a/loginrec.c b/loginrec.c index 93e48d517..e5289deb8 100644 --- a/loginrec.c +++ b/loginrec.c @@ -156,6 +156,7 @@ #include +#include #include #include #ifdef HAVE_PATHS_H diff --git a/mac.c b/mac.c index eab453a41..de346ed20 100644 --- a/mac.c +++ b/mac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mac.c,v 1.34 2017/05/08 22:57:38 djm Exp $ */ +/* $OpenBSD: mac.c,v 1.35 2019/09/06 04:53:27 djm Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * @@ -30,6 +30,7 @@ #include #include #include +#include #include "digest.h" #include "hmac.h" diff --git a/ssh-keygen.c b/ssh-keygen.c index 7d4f33e46..cb00a1cf8 100644 --- a/ssh-keygen.c +++ b/ssh-keygen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-keygen.c,v 1.346 2019/09/03 20:51:49 naddy Exp $ */ +/* $OpenBSD: ssh-keygen.c,v 1.347 2019/09/06 04:53:27 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1994 Tatu Ylonen , Espoo, Finland @@ -24,6 +24,7 @@ #include "openbsd-compat/openssl-compat.h" #endif +#include #include #include #include diff --git a/ssh-keysign.c b/ssh-keysign.c index a4a1b8c21..218caecdf 100644 --- a/ssh-keysign.c +++ b/ssh-keysign.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-keysign.c,v 1.58 2019/06/14 03:28:19 djm Exp $ */ +/* $OpenBSD: ssh-keysign.c,v 1.59 2019/09/06 04:53:27 djm Exp $ */ /* * Copyright (c) 2002 Markus Friedl. All rights reserved. * @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include diff --git a/ssh-pkcs11-helper.c b/ssh-pkcs11-helper.c index cd79db2ae..67094111f 100644 --- a/ssh-pkcs11-helper.c +++ b/ssh-pkcs11-helper.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-pkcs11-helper.c,v 1.19 2019/06/06 05:13:13 otto Exp $ */ +/* $OpenBSD: ssh-pkcs11-helper.c,v 1.20 2019/09/06 04:53:27 djm Exp $ */ /* * Copyright (c) 2010 Markus Friedl. All rights reserved. * @@ -24,6 +24,7 @@ #include "openbsd-compat/sys-queue.h" +#include #include #include #include diff --git a/ssh_api.c b/ssh_api.c index 57509973b..255adc6cf 100644 --- a/ssh_api.c +++ b/ssh_api.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh_api.c,v 1.15 2019/01/21 10:38:54 djm Exp $ */ +/* $OpenBSD: ssh_api.c,v 1.16 2019/09/06 04:53:27 djm Exp $ */ /* * Copyright (c) 2012 Markus Friedl. All rights reserved. * @@ -17,6 +17,11 @@ #include "includes.h" +#include + +#include +#include + #include "ssh_api.h" #include "compat.h" #include "log.h" diff --git a/sshbuf-getput-basic.c b/sshbuf-getput-basic.c index 27058d5bb..ffa20a02c 100644 --- a/sshbuf-getput-basic.c +++ b/sshbuf-getput-basic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshbuf-getput-basic.c,v 1.8 2019/07/14 23:32:27 djm Exp $ */ +/* $OpenBSD: sshbuf-getput-basic.c,v 1.9 2019/09/06 04:53:27 djm Exp $ */ /* * Copyright (c) 2011 Damien Miller * @@ -24,6 +24,7 @@ #include #include #include +#include #include "ssherr.h" #include "sshbuf.h" -- cgit v1.2.3 From d0c3ac427f6c52b872d6617421421dd791664445 Mon Sep 17 00:00:00 2001 From: "djm@openbsd.org" Date: Wed, 2 Oct 2019 00:42:30 +0000 Subject: upstream: remove some duplicate #includes OpenBSD-Commit-ID: ed6827ab921eff8027669848ef4f70dc1da4098c --- auth-rhosts.c | 3 +-- auth.c | 3 +-- sftp-glob.c | 3 +-- sftp.c | 3 +-- ssh-keysign.c | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) (limited to 'auth.c') diff --git a/auth-rhosts.c b/auth-rhosts.c index 63c1c8acb..7a10210b6 100644 --- a/auth-rhosts.c +++ b/auth-rhosts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth-rhosts.c,v 1.50 2019/06/28 13:35:04 deraadt Exp $ */ +/* $OpenBSD: auth-rhosts.c,v 1.51 2019/10/02 00:42:30 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -38,7 +38,6 @@ #include "sshkey.h" #include "servconf.h" #include "canohost.h" -#include "sshkey.h" #include "hostfile.h" #include "auth.h" diff --git a/auth.c b/auth.c index 61fb1feb3..ca450f4e4 100644 --- a/auth.c +++ b/auth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth.c,v 1.140 2019/09/06 04:53:27 djm Exp $ */ +/* $OpenBSD: auth.c,v 1.141 2019/10/02 00:42:30 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -73,7 +73,6 @@ #endif #include "authfile.h" #include "monitor_wrap.h" -#include "authfile.h" #include "ssherr.h" #include "compat.h" #include "channels.h" diff --git a/sftp-glob.c b/sftp-glob.c index 43a1bebad..c196c51e5 100644 --- a/sftp-glob.c +++ b/sftp-glob.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp-glob.c,v 1.27 2015/01/14 13:54:13 djm Exp $ */ +/* $OpenBSD: sftp-glob.c,v 1.28 2019/10/02 00:42:30 djm Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller * @@ -25,7 +25,6 @@ #include #include #include -#include #include "xmalloc.h" #include "sftp.h" diff --git a/sftp.c b/sftp.c index fa833d25d..b66037f16 100644 --- a/sftp.c +++ b/sftp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp.c,v 1.194 2019/07/10 07:04:27 tb Exp $ */ +/* $OpenBSD: sftp.c,v 1.195 2019/10/02 00:42:30 djm Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller * @@ -53,7 +53,6 @@ typedef void EditLine; #include #include #include -#include #ifdef HAVE_UTIL_H # include diff --git a/ssh-keysign.c b/ssh-keysign.c index 2ff86756e..3ede407d3 100644 --- a/ssh-keysign.c +++ b/ssh-keysign.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-keysign.c,v 1.60 2019/09/06 05:23:55 djm Exp $ */ +/* $OpenBSD: ssh-keysign.c,v 1.61 2019/10/02 00:42:30 djm Exp $ */ /* * Copyright (c) 2002 Markus Friedl. All rights reserved. * @@ -58,7 +58,6 @@ #include "pathnames.h" #include "readconf.h" #include "uidswap.h" -#include "sshkey.h" #include "ssherr.h" extern char *__progname; -- cgit v1.2.3