ITS#10309 Check for strdup allocation failures

This commit is contained in:
Ondřej Kuzník 2025-02-20 12:57:57 +00:00 committed by Quanah Gibson-Mount
parent fc34ad5dc8
commit 722fe5012d
2 changed files with 24 additions and 0 deletions

View file

@ -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 );
}
}

View file

@ -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);