handle sysconf(SC_OPEN_MAX) returning > INT_MAX;
bz3581; ok dtucker
This commit is contained in:
parent
c1c2ca1365
commit
cfca6f17e6
|
@ -132,16 +132,21 @@ fdlim_get(int hard)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE)
|
#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE)
|
||||||
struct rlimit rlfd;
|
struct rlimit rlfd;
|
||||||
|
rlim_t lim;
|
||||||
|
|
||||||
if (getrlimit(RLIMIT_NOFILE, &rlfd) == -1 ||
|
if (getrlimit(RLIMIT_NOFILE, &rlfd) == -1)
|
||||||
(hard ? rlfd.rlim_max : rlfd.rlim_cur) < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
if ((hard ? rlfd.rlim_max : rlfd.rlim_cur) == RLIM_INFINITY ||
|
lim = hard ? rlfd.rlim_max : rlfd.rlim_cur;
|
||||||
(hard ? rlfd.rlim_max : rlfd.rlim_cur) > INT_MAX)
|
if (lim <= 0)
|
||||||
return SSH_SYSFDMAX;
|
return -1;
|
||||||
return hard ? rlfd.rlim_max : rlfd.rlim_cur;
|
if (lim == RLIM_INFINITY)
|
||||||
|
lim = SSH_SYSFDMAX;
|
||||||
|
if (lim >= INT_MAX)
|
||||||
|
lim = INT_MAX;
|
||||||
|
return lim;
|
||||||
#else
|
#else
|
||||||
return SSH_SYSFDMAX;
|
return (SSH_SYSFDMAX <= 0) ? -1 :
|
||||||
|
((SSH_SYSFDMAX >= INT_MAX) ? INT_MAX : SSH_SYSFDMAX);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue