X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Ftls.c;h=53c4e3b0804090d6387be7feaa05873f3a9bc527;hb=9e0958d5bc342e2f35f6ee8aaa6cf179b2d55085;hp=abe58ce7d3d9316d55747adeaa4145477cc812ca;hpb=5f53b747a5054cfecd6ade134fea27330062ffb8;p=openldap diff --git a/libraries/libldap/tls.c b/libraries/libldap/tls.c index abe58ce7d3..53c4e3b080 100644 --- a/libraries/libldap/tls.c +++ b/libraries/libldap/tls.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -10,8 +11,8 @@ #ifdef HAVE_TLS #include -#include +#include #include #include #include @@ -378,21 +379,19 @@ ldap_pvt_tls_config( struct ldapoptions *lo, int option, const char *arg ) ( strcasecmp( arg, "true" ) == 0 ) ); return ldap_pvt_tls_set_option( NULL, option, (void *) &i ); case LDAP_OPT_X_TLS: + i = -1; if ( strcasecmp( arg, "never" ) == 0 ) - return ldap_pvt_tls_set_option( lo, option, - LDAP_OPT_X_TLS_NEVER ); + i = LDAP_OPT_X_TLS_NEVER ; if ( strcasecmp( arg, "demand" ) == 0 ) - return ldap_pvt_tls_set_option( lo, option, - LDAP_OPT_X_TLS_DEMAND ); + i = LDAP_OPT_X_TLS_DEMAND ; if ( strcasecmp( arg, "allow" ) == 0 ) - return ldap_pvt_tls_set_option( lo, option, - LDAP_OPT_X_TLS_ALLOW ); + i = LDAP_OPT_X_TLS_ALLOW ; if ( strcasecmp( arg, "try" ) == 0 ) - return ldap_pvt_tls_set_option( lo, option, - LDAP_OPT_X_TLS_TRY ); + i = LDAP_OPT_X_TLS_TRY ; if ( strcasecmp( arg, "hard" ) == 0 ) - return ldap_pvt_tls_set_option( lo, option, - LDAP_OPT_X_TLS_HARD ); + i = LDAP_OPT_X_TLS_HARD ; + if (i >= 0) + return ldap_pvt_tls_set_option( lo, option, &i ); return -1; default: return -1; @@ -414,19 +413,19 @@ ldap_pvt_tls_get_option( struct ldapoptions *lo, int option, void *arg ) break; case LDAP_OPT_X_TLS_CACERTFILE: *(char **)arg = tls_opt_cacertfile ? - strdup( tls_opt_cacertfile ) : NULL; + LDAP_STRDUP( tls_opt_cacertfile ) : NULL; break; case LDAP_OPT_X_TLS_CACERTDIR: *(char **)arg = tls_opt_cacertdir ? - strdup( tls_opt_cacertdir ) : NULL; + LDAP_STRDUP( tls_opt_cacertdir ) : NULL; break; case LDAP_OPT_X_TLS_CERTFILE: *(char **)arg = tls_opt_certfile ? - strdup( tls_opt_certfile ) : NULL; + LDAP_STRDUP( tls_opt_certfile ) : NULL; break; case LDAP_OPT_X_TLS_KEYFILE: *(char **)arg = tls_opt_keyfile ? - strdup( tls_opt_keyfile ) : NULL; + LDAP_STRDUP( tls_opt_keyfile ) : NULL; break; case LDAP_OPT_X_TLS_REQUIRE_CERT: *(int *)arg = tls_opt_require_cert; @@ -466,26 +465,26 @@ ldap_pvt_tls_set_option( struct ldapoptions *lo, int option, void *arg ) switch( option ) { case LDAP_OPT_X_TLS_CACERTFILE: if ( tls_opt_cacertfile ) free( tls_opt_cacertfile ); - tls_opt_cacertfile = arg ? strdup( (char *) arg ) : NULL; + tls_opt_cacertfile = arg ? LDAP_STRDUP( (char *) arg ) : NULL; break; case LDAP_OPT_X_TLS_CACERTDIR: if ( tls_opt_cacertdir ) free( tls_opt_cacertdir ); - tls_opt_cacertdir = arg ? strdup( (char *) arg ) : NULL; + tls_opt_cacertdir = arg ? LDAP_STRDUP( (char *) arg ) : NULL; break; case LDAP_OPT_X_TLS_CERTFILE: if ( tls_opt_certfile ) free( tls_opt_certfile ); - tls_opt_certfile = arg ? strdup( (char *) arg ) : NULL; + tls_opt_certfile = arg ? LDAP_STRDUP( (char *) arg ) : NULL; break; case LDAP_OPT_X_TLS_KEYFILE: if ( tls_opt_keyfile ) free( tls_opt_keyfile ); - tls_opt_keyfile = arg ? strdup( (char *) arg ) : NULL; + tls_opt_keyfile = arg ? LDAP_STRDUP( (char *) arg ) : NULL; break; case LDAP_OPT_X_TLS_REQUIRE_CERT: tls_opt_require_cert = * (int *) arg; break; case LDAP_OPT_X_TLS_CIPHER_SUITE: if ( tls_opt_ciphersuite ) free( tls_opt_ciphersuite ); - tls_opt_ciphersuite = arg ? strdup( (char *) arg ) : NULL; + tls_opt_ciphersuite = arg ? LDAP_STRDUP( (char *) arg ) : NULL; break; default: return -1;