openldap-syncrepl-unset-tls-options.patch 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. allow unsetting of tls_* syncrepl options
  2. Author: Patrick Monnerat <pm@datasphere.ch>
  3. Upstream ITS: #7042
  4. Resolves: #734187
  5. diff --git a/libraries/libldap/tls2.c b/libraries/libldap/tls2.c
  6. index 654a4bf..10b993b 100644
  7. --- a/libraries/libldap/tls2.c
  8. +++ b/libraries/libldap/tls2.c
  9. @@ -735,27 +735,27 @@ ldap_pvt_tls_set_option( LDAP *ld, int option, void *arg )
  10. return 0;
  11. case LDAP_OPT_X_TLS_CACERTFILE:
  12. if ( lo->ldo_tls_cacertfile ) LDAP_FREE( lo->ldo_tls_cacertfile );
  13. - lo->ldo_tls_cacertfile = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
  14. + lo->ldo_tls_cacertfile = (arg && *(char *)arg) ? LDAP_STRDUP( (char *) arg ) : NULL;
  15. return 0;
  16. case LDAP_OPT_X_TLS_CACERTDIR:
  17. if ( lo->ldo_tls_cacertdir ) LDAP_FREE( lo->ldo_tls_cacertdir );
  18. - lo->ldo_tls_cacertdir = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
  19. + lo->ldo_tls_cacertdir = (arg && *(char *)arg) ? LDAP_STRDUP( (char *) arg ) : NULL;
  20. return 0;
  21. case LDAP_OPT_X_TLS_CERTFILE:
  22. if ( lo->ldo_tls_certfile ) LDAP_FREE( lo->ldo_tls_certfile );
  23. - lo->ldo_tls_certfile = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
  24. + lo->ldo_tls_certfile = (arg && *(char *)arg) ? LDAP_STRDUP( (char *) arg ) : NULL;
  25. return 0;
  26. case LDAP_OPT_X_TLS_KEYFILE:
  27. if ( lo->ldo_tls_keyfile ) LDAP_FREE( lo->ldo_tls_keyfile );
  28. - lo->ldo_tls_keyfile = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
  29. + lo->ldo_tls_keyfile = (arg && *(char *)arg) ? LDAP_STRDUP( (char *) arg ) : NULL;
  30. return 0;
  31. case LDAP_OPT_X_TLS_DHFILE:
  32. if ( lo->ldo_tls_dhfile ) LDAP_FREE( lo->ldo_tls_dhfile );
  33. - lo->ldo_tls_dhfile = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
  34. + lo->ldo_tls_dhfile = (arg && *(char *)arg) ? LDAP_STRDUP( (char *) arg ) : NULL;
  35. return 0;
  36. case LDAP_OPT_X_TLS_CRLFILE: /* GnuTLS only */
  37. if ( lo->ldo_tls_crlfile ) LDAP_FREE( lo->ldo_tls_crlfile );
  38. - lo->ldo_tls_crlfile = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
  39. + lo->ldo_tls_crlfile = (arg && *(char *)arg) ? LDAP_STRDUP( (char *) arg ) : NULL;
  40. return 0;
  41. case LDAP_OPT_X_TLS_REQUIRE_CERT:
  42. if ( !arg ) return -1;
  43. @@ -783,7 +783,7 @@ ldap_pvt_tls_set_option( LDAP *ld, int option, void *arg )
  44. #endif
  45. case LDAP_OPT_X_TLS_CIPHER_SUITE:
  46. if ( lo->ldo_tls_ciphersuite ) LDAP_FREE( lo->ldo_tls_ciphersuite );
  47. - lo->ldo_tls_ciphersuite = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
  48. + lo->ldo_tls_ciphersuite = (arg && *(char *)arg) ? LDAP_STRDUP( (char *) arg ) : NULL;
  49. return 0;
  50. case LDAP_OPT_X_TLS_PROTOCOL_MIN:
  51. @@ -794,7 +794,7 @@ ldap_pvt_tls_set_option( LDAP *ld, int option, void *arg )
  52. if ( ld != NULL )
  53. return -1;
  54. if ( lo->ldo_tls_randfile ) LDAP_FREE (lo->ldo_tls_randfile );
  55. - lo->ldo_tls_randfile = arg ? LDAP_STRDUP( (char *) arg ) : NULL;
  56. + lo->ldo_tls_randfile = (arg && *(char *)arg) ? LDAP_STRDUP( (char *) arg ) : NULL;
  57. break;
  58. case LDAP_OPT_X_TLS_NEWCTX:
  59. if ( !arg ) return -1;