[openssh-commits] [openssh] 02/04: upstream: handle rlimits > INT_MAX (rlim_t is u64); ok dtucker
git+noreply at mindrot.org
git+noreply at mindrot.org
Wed Jun 21 15:14:06 AEST 2023
This is an automated email from the git hooks/post-receive script.
djm pushed a commit to branch master
in repository openssh.
commit a69062f1695ac9c3c3dea29d3044c72aaa6af0ea
Author: djm at openbsd.org <djm at openbsd.org>
Date: Wed Jun 21 05:06:04 2023 +0000
upstream: handle rlimits > INT_MAX (rlim_t is u64); ok dtucker
bz3581
OpenBSD-Commit-ID: 31cf59c041becc0e5ccb0a77106f812c4cd1cd74
---
ssh-keyscan.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/ssh-keyscan.c b/ssh-keyscan.c
index a53188c7..96c6e906 100644
--- a/ssh-keyscan.c
+++ b/ssh-keyscan.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-keyscan.c,v 1.152 2023/03/31 04:21:56 djm Exp $ */
+/* $OpenBSD: ssh-keyscan.c,v 1.153 2023/06/21 05:06:04 djm Exp $ */
/*
* Copyright 1995, 1996 by David Mazieres <dm at lcs.mit.edu>.
*
@@ -23,6 +23,7 @@
#include <openssl/bn.h>
#endif
+#include <limits.h>
#include <netdb.h>
#include <errno.h>
#ifdef HAVE_POLL_H
@@ -132,12 +133,13 @@ fdlim_get(int hard)
#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE)
struct rlimit rlfd;
- if (getrlimit(RLIMIT_NOFILE, &rlfd) == -1)
- return (-1);
- if ((hard ? rlfd.rlim_max : rlfd.rlim_cur) == RLIM_INFINITY)
+ if (getrlimit(RLIMIT_NOFILE, &rlfd) == -1 ||
+ (hard ? rlfd.rlim_max : rlfd.rlim_cur) < 0)
+ return -1;
+ if ((hard ? rlfd.rlim_max : rlfd.rlim_cur) == RLIM_INFINITY ||
+ (hard ? rlfd.rlim_max : rlfd.rlim_cur) > INT_MAX)
return SSH_SYSFDMAX;
- else
- return hard ? rlfd.rlim_max : rlfd.rlim_cur;
+ return hard ? rlfd.rlim_max : rlfd.rlim_cur;
#else
return SSH_SYSFDMAX;
#endif
--
To stop receiving notification emails like this one, please contact
djm at mindrot.org.
More information about the openssh-commits
mailing list