From: Kurt Zeilenga Date: Wed, 30 Mar 2005 21:53:01 +0000 (+0000) Subject: ITS#3614: prevent overflow when using result of sysconf(_SC_OPEN_MAX) X-Git-Tag: OPENLDAP_AC_BP~1036 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=94a9f8489509f094366952a6ca9414c8fce22ddd;p=openldap ITS#3614: prevent overflow when using result of sysconf(_SC_OPEN_MAX) --- diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c index ae5225ca00..e8e0c1eb07 100644 --- a/libraries/libldap/os-ip.c +++ b/libraries/libldap/os-ip.c @@ -871,14 +871,14 @@ int ldap_int_tblsize = 0; void ldap_int_ip_init( void ) { - int tblsize; - #if defined( HAVE_SYSCONF ) - tblsize = sysconf( _SC_OPEN_MAX ); + long tblsize = sysconf( _SC_OPEN_MAX ); + if( tblsize > INT_MAX ) tblsize = INT_MAX; + #elif defined( HAVE_GETDTABLESIZE ) - tblsize = getdtablesize(); + int tblsize = getdtablesize(); #else - tblsize = FD_SETSIZE; + int tblsize = FD_SETSIZE; #endif /* !USE_SYSCONF */ #ifdef FD_SETSIZE