From 94a9f8489509f094366952a6ca9414c8fce22ddd Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 30 Mar 2005 21:53:01 +0000 Subject: [PATCH] ITS#3614: prevent overflow when using result of sysconf(_SC_OPEN_MAX) --- libraries/libldap/os-ip.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 -- 2.39.5