From: Ondřej Kuzník Date: Thu, 20 Feb 2025 12:57:57 +0000 (+0000) Subject: ITS#10309 Check for strdup allocation failures X-Git-Tag: OPENLDAP_REL_ENG_2_5_20~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=722fe5012d7de9f945c69d38918c4c82bbd9c900;p=thirdparty%2Fopenldap.git ITS#10309 Check for strdup allocation failures --- diff --git a/clients/tools/common.c b/clients/tools/common.c index 4823202775..516c52cc6f 100644 --- a/clients/tools/common.c +++ b/clients/tools/common.c @@ -780,6 +780,9 @@ tool_args( int argc, char **argv ) exit( EXIT_FAILURE ); } ldapuri = ber_strdup( optarg ); + if ( ldapuri == NULL ) { + exit( EXIT_FAILURE ); + } break; case 'I': #ifdef HAVE_CYRUS_SASL @@ -980,6 +983,9 @@ tool_args( int argc, char **argv ) break; case 'w': /* password */ passwd.bv_val = ber_strdup( optarg ); + if ( passwd.bv_val == NULL ) { + exit( EXIT_FAILURE ); + } { char* p; @@ -1481,6 +1487,9 @@ tool_bind( LDAP *ld ) tool_exit( ld, EXIT_FAILURE ); } passwd.bv_val = ber_strdup( pw ); + if ( passwd.bv_val == NULL ) { + tool_exit( ld, EXIT_FAILURE ); + } passwd.bv_len = strlen( passwd.bv_val ); } } diff --git a/clients/tools/ldapvc.c b/clients/tools/ldapvc.c index e359611882..3608960e7d 100644 --- a/clients/tools/ldapvc.c +++ b/clients/tools/ldapvc.c @@ -165,6 +165,9 @@ handle_private_option( int i ) } vc_sasl_mech = ber_strdup(cvalue); + if (vc_sasl_mech == NULL) { + exit(EXIT_FAILURE); + } #else #endif @@ -182,6 +185,9 @@ handle_private_option( int i ) } vc_sasl_realm = ber_strdup(cvalue); + if (vc_sasl_realm == NULL) { + exit(EXIT_FAILURE); + } #else fprintf(stderr, _("%s: not compiled with SASL support\n"), prog); @@ -202,6 +208,9 @@ handle_private_option( int i ) } vc_sasl_authcid = ber_strdup(cvalue); + if (vc_sasl_authcid == NULL) { + exit(EXIT_FAILURE); + } #else fprintf(stderr, _("%s: not compiled with SASL support\n"), prog); @@ -222,6 +231,9 @@ handle_private_option( int i ) } vc_sasl_authzid = ber_strdup(cvalue); + if (vc_sasl_authzid == NULL) { + exit(EXIT_FAILURE); + } #else fprintf(stderr, _("%s: not compiled with SASL support\n"), prog); @@ -242,6 +254,9 @@ handle_private_option( int i ) } vc_sasl_secprops = ber_strdup(cvalue); + if (vc_sasl_secprops == NULL) { + exit(EXIT_FAILURE); + } #else fprintf(stderr, _("%s: not compiled with SASL support\n"), prog);