]> git.sur5r.net Git - openldap/commitdiff
ITS#3614: prevent overflow when using result of sysconf(_SC_OPEN_MAX)
authorKurt Zeilenga <kurt@openldap.org>
Wed, 30 Mar 2005 21:53:01 +0000 (21:53 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 30 Mar 2005 21:53:01 +0000 (21:53 +0000)
libraries/libldap/os-ip.c

index ae5225ca00cccec0054dced619f1f8ffd985b8d8..e8e0c1eb075659f47f4127514c94742c7ee13714 100644 (file)
@@ -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