upstream: handle rlimits > INT_MAX (rlim_t is u64); ok dtucker
bz3581 OpenBSD-Commit-ID: 31cf59c041becc0e5ccb0a77106f812c4cd1cd74
This commit is contained in:
parent
8d33f2aa6b
commit
a69062f169
|
@ -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@lcs.mit.edu>.
|
* Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>.
|
||||||
*
|
*
|
||||||
|
@ -23,6 +23,7 @@
|
||||||
#include <openssl/bn.h>
|
#include <openssl/bn.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#ifdef HAVE_POLL_H
|
#ifdef HAVE_POLL_H
|
||||||
|
@ -132,11 +133,12 @@ fdlim_get(int hard)
|
||||||
#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE)
|
#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE)
|
||||||
struct rlimit rlfd;
|
struct rlimit rlfd;
|
||||||
|
|
||||||
if (getrlimit(RLIMIT_NOFILE, &rlfd) == -1)
|
if (getrlimit(RLIMIT_NOFILE, &rlfd) == -1 ||
|
||||||
return (-1);
|
(hard ? rlfd.rlim_max : rlfd.rlim_cur) < 0)
|
||||||
if ((hard ? rlfd.rlim_max : rlfd.rlim_cur) == RLIM_INFINITY)
|
return -1;
|
||||||
|
if ((hard ? rlfd.rlim_max : rlfd.rlim_cur) == RLIM_INFINITY ||
|
||||||
|
(hard ? rlfd.rlim_max : rlfd.rlim_cur) > INT_MAX)
|
||||||
return SSH_SYSFDMAX;
|
return SSH_SYSFDMAX;
|
||||||
else
|
|
||||||
return hard ? rlfd.rlim_max : rlfd.rlim_cur;
|
return hard ? rlfd.rlim_max : rlfd.rlim_cur;
|
||||||
#else
|
#else
|
||||||
return SSH_SYSFDMAX;
|
return SSH_SYSFDMAX;
|
||||||
|
|
Loading…
Reference in New Issue