diff options
author | Bodo Möller <bodo@openssl.org> | 1999-05-14 12:40:39 +0000 |
---|---|---|
committer | Bodo Möller <bodo@openssl.org> | 1999-05-14 12:40:39 +0000 |
commit | 2a82c7cf252387b67d79383d518fad4a10bb253e (patch) | |
tree | a3ae765c754c1f4b54cdc34f64e195159f3883f8 /ssl/ssl_cert.c | |
parent | d36bcdf5ca819f1f8efb5eb0897f80864e110ad7 (diff) |
Various bugfixes: Uses locking for some more of the stuff that is not
thread-safe (where thread-safe counterparts are not available on all
platforms), and don't memcpy to NULL-pointers
Submitted by: Anonymous
Reviewed by: Bodo Moeller
Also, clean up htons vs. ntohs confusions.
Diffstat (limited to 'ssl/ssl_cert.c')
-rw-r--r-- | ssl/ssl_cert.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c index 53b77797a5..bd68730cd3 100644 --- a/ssl/ssl_cert.c +++ b/ssl/ssl_cert.c @@ -673,14 +673,18 @@ err: int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, const char *dir) { - DIR *d=opendir(dir); + DIR *d; struct dirent *dstruct; + int ret = 0; + + CRYPTO_w_lock(CRYPTO_LOCK_READDIR); + d = opendir(dir); /* Note that a side effect is that the CAs will be sorted by name */ if(!d) { SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,ERR_R_MALLOC_FAILURE); - return 0; + goto err; } while((dstruct=readdir(d))) @@ -690,15 +694,18 @@ int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, if(strlen(dir)+strlen(dstruct->d_name)+2 > sizeof buf) { SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,SSL_R_PATH_TOO_LONG); - return 0; + goto err; } sprintf(buf,"%s/%s",dir,dstruct->d_name); if(!SSL_add_file_cert_subjects_to_stack(stack,buf)) - return 0; + goto err; } + ret = 1; - return 1; +err: + CRYPTO_w_unlock(CRYPTO_LOCK_READDIR); + return ret; } #endif |