From: djm Date: Wed, 21 Jun 2023 05:06:04 +0000 (+0000) Subject: handle rlimits > INT_MAX (rlim_t is u64); ok dtucker X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=cdc6f5c1e5538503125f1e11efcd2c2fe0368d98;p=openbsd handle rlimits > INT_MAX (rlim_t is u64); ok dtucker bz3581 --- diff --git a/usr.bin/ssh/ssh-keyscan.c b/usr.bin/ssh/ssh-keyscan.c index 159023dc2ee..6a43d75fe34 100644 --- a/usr.bin/ssh/ssh-keyscan.c +++ b/usr.bin/ssh/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 . * @@ -18,6 +18,7 @@ #endif #include +#include #include #include #include @@ -125,10 +126,10 @@ fdlim_get(int hard) if (getrlimit(RLIMIT_NOFILE, &rlfd) == -1) return (-1); - if ((hard ? rlfd.rlim_max : rlfd.rlim_cur) == RLIM_INFINITY) + if ((hard ? rlfd.rlim_max : rlfd.rlim_cur) == RLIM_INFINITY || + (hard ? rlfd.rlim_max : rlfd.rlim_cur) > INT_MAX) return sysconf(_SC_OPEN_MAX); - else - return hard ? rlfd.rlim_max : rlfd.rlim_cur; + return hard ? rlfd.rlim_max : rlfd.rlim_cur; } static int