]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#10309 Check for strdup allocation failures
authorOndřej Kuzník <ondra@mistotebe.net>
Thu, 20 Feb 2025 12:57:57 +0000 (12:57 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Tue, 6 May 2025 15:09:03 +0000 (15:09 +0000)
clients/tools/common.c
clients/tools/ldapvc.c

index 4823202775defbdee9547a9a10a366329e6c7467..516c52cc6fb485feffb52f1495845f11a84df7d6 100644 (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 );
                }
        }
index e3596118821c75bfe99a1ea86a9cdcb988b26b26..3608960e7d26802ec4c1401266869857caf33a52 100644 (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);