]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/add.c
ITS#7428 Use non-blocking IO during SSL Handshake
[openldap] / libraries / libldap / add.c
index 95b0742a375ed38293c1385d823239efcc74f266..33f7f61199ec6dc9506dc3687ce8a333663c74ab 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2006 The OpenLDAP Foundation.
+ * Copyright 1998-2012 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -151,9 +151,32 @@ ldap_add_ext(
                /* for each attribute in the entry... */
                for ( i = 0; attrs[i] != NULL; i++ ) {
                        if ( ( attrs[i]->mod_op & LDAP_MOD_BVALUES) != 0 ) {
+                               int j;
+
+                               if ( attrs[i]->mod_bvalues == NULL ) {
+                                       ld->ld_errno = LDAP_PARAM_ERROR;
+                                       ber_free( ber, 1 );
+                                       return ld->ld_errno;
+                               }
+
+                               for ( j = 0; attrs[i]->mod_bvalues[ j ] != NULL; j++ ) {
+                                       if ( attrs[i]->mod_bvalues[ j ]->bv_val == NULL ) {
+                                               ld->ld_errno = LDAP_PARAM_ERROR;
+                                               ber_free( ber, 1 );
+                                               return ld->ld_errno;
+                                       }
+                               }
+
                                rc = ber_printf( ber, "{s[V]N}", attrs[i]->mod_type,
                                    attrs[i]->mod_bvalues );
+
                        } else {
+                               if ( attrs[i]->mod_values == NULL ) {
+                                       ld->ld_errno = LDAP_PARAM_ERROR;
+                                       ber_free( ber, 1 );
+                                       return ld->ld_errno;
+                               }
+
                                rc = ber_printf( ber, "{s[v]N}", attrs[i]->mod_type,
                                    attrs[i]->mod_values );
                        }
@@ -208,7 +231,7 @@ ldap_add_ext_s(
        if ( rc != LDAP_SUCCESS )
                return( rc );
 
-       if ( ldap_result( ld, msgid, LDAP_MSG_ALL, (struct timeval *) NULL, &res ) == -1 )
+       if ( ldap_result( ld, msgid, LDAP_MSG_ALL, (struct timeval *) NULL, &res ) == -1 || !res )
                return( ld->ld_errno );
 
        return( ldap_result2error( ld, res, 1 ) );