[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
POSIX dir browsing breaks MSVC build with TLS (ITS#1954)
Full_Name: Kervin Pierre
Version: 2.1.3
OS: Windows 2000
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (163.118.3.50)
libraries/libldap/tls.c in get_ca_list( char * bundle, char * dir ) function
POSIX functions opendir, readdir, and closedir are not available on WIN32.
findfirst, findnext, and findclose can be used as substitutes.
Here's a preliminary and untested patch. I'm sorry but I can't test it right
now.
--- ../../../openldap-2.1.3/libraries/libldap/tls.c 2002-07-09
21:23:42.000000000 -0400
+++ tls.c 2002-07-15 21:32:43.000000000 -0400
@@ -24,6 +24,10 @@
#ifdef HAVE_TLS
+#ifdef WIN32
+#include <io.h>
+#endif
+
#ifdef LDAP_R_COMPILE
#include <ldap_pvt_thread.h>
#endif
@@ -342,15 +346,25 @@
ca_list = SSL_load_client_CA_file( bundle );
}
if ( dir ) {
+ char *filename;
+#ifdef WIN32
+ struct _finddata_t c_file;
+ long hFile;
+#else
DIR *dirp;
struct dirent *d;
+#endif
char buf[MAXPATHLEN];
int l = strlen(dir), freeit = 0;
if (l > sizeof(buf))
goto done;
-
+#ifdef WIN32
+ if( (hFile = _findfirst( "*.*", &c_file )) == -1L )
+ goto done;
+#else
dirp = opendir( dir );
+#endif
if ( !ca_list ) {
ca_list = sk_X509_NAME_new_null();
@@ -359,19 +373,33 @@
strcpy(buf, dir);
+#ifdef WIN32
+ do
+ {
+ filename = c_file.name;
+ if( ! (c_file.attrib & _A_NORMAL ) )
+ continue;
+#else
while ( dirp ) {
if ( ( d = readdir( dirp )) == NULL) {
closedir( dirp );
break;
}
- if (l + sizeof(LDAP_DIRSEP) + NAMLEN(d) > sizeof(buf))
+ filename = d->d_name;
+#endif
+ if (l + sizeof(LDAP_DIRSEP) + strlen(filename) > sizeof(buf))
continue;
- sprintf( buf+l, LDAP_DIRSEP "%s", d->d_name );
+ sprintf( buf+l, LDAP_DIRSEP "%s", filename );
if ( SSL_add_file_cert_subjects_to_stack(ca_list, buf)) {
freeit = 0;
}
+#ifdef WIN32
+ } while ( _findnext( hFile, &c_file ) == 0 );
+ _findclose( hFile );
+#else
}
+#endif
if ( freeit ) {
sk_X509_NAME_free( ca_list );
ca_list = NULL;