]> 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, 4 Mar 2025 19:41:59 +0000 (19:41 +0000)
clients/tools/common.c
clients/tools/ldapvc.c

index 8249a960bf6a1870ee47bed15d20afccb80bf6d0..1e428cc372285e3dfc8d212710a0c36a125d5041 100644 (file)
@@ -794,6 +794,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
@@ -994,6 +997,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;
 
@@ -1504,6 +1510,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);