]> git.sur5r.net Git - openldap/commitdiff
ITS#7149 fix back-shell/back-perl Modify with binary values
authorHoward Chu <hyc@openldap.org>
Thu, 29 Mar 2012 13:05:15 +0000 (06:05 -0700)
committerHoward Chu <hyc@openldap.org>
Thu, 29 Mar 2012 13:05:15 +0000 (06:05 -0700)
servers/slapd/back-perl/modify.c
servers/slapd/back-shell/modify.c

index d05f71dec0b0b4e4cc589db1fbcdd351b1c5e96c..237a782de276f542bb70a1340070a2669f875d45 100644 (file)
@@ -42,26 +42,27 @@ perl_back_modify(
 
                        switch ( mods->sm_op & ~LDAP_MOD_BVALUES ) {
                        case LDAP_MOD_ADD:
-                               XPUSHs(sv_2mortal(newSVpv("ADD", 0 )));
+                               XPUSHs(sv_2mortal(newSVpv("ADD", STRLENOF("ADD") )));
                                break;
                                
                        case LDAP_MOD_DELETE:
-                               XPUSHs(sv_2mortal(newSVpv("DELETE", 0 )));
+                               XPUSHs(sv_2mortal(newSVpv("DELETE", STRLENOF("DELETE") )));
                                break;
                                
                        case LDAP_MOD_REPLACE:
-                               XPUSHs(sv_2mortal(newSVpv("REPLACE", 0 )));
+                               XPUSHs(sv_2mortal(newSVpv("REPLACE", STRLENOF("REPLACE") )));
                                break;
                        }
 
                        
-                       XPUSHs(sv_2mortal(newSVpv( mods->sm_desc->ad_cname.bv_val, 0 )));
+                       XPUSHs(sv_2mortal(newSVpv( mods->sm_desc->ad_cname.bv_val,
+                               mods->sm_desc->ad_cname.bv_len )));
 
                        for ( i = 0;
                                mods->sm_values != NULL && mods->sm_values[i].bv_val != NULL;
                                i++ )
                        {
-                               XPUSHs(sv_2mortal(newSVpv( mods->sm_values[i].bv_val, 0 )));
+                               XPUSHs(sv_2mortal(newSVpv( mods->sm_values[i].bv_val, mods->sm_values[i].bv_len )));
                        }
 
                        /* Fix delete attrib without value. */
index ecf05450bf2d5db342de738b4ab9b9105d507791..5df09628c1ff2b1da875b47e4ef36ca9053bc9bb 100644 (file)
@@ -37,6 +37,7 @@
 
 #include "slap.h"
 #include "shell.h"
+#include "ldif.h"
 
 int
 shell_back_modify(
@@ -87,8 +88,6 @@ shell_back_modify(
        for ( ; ml != NULL; ml = ml->sml_next ) {
                mod = &ml->sml_mod;
 
-               /* FIXME: should use LDIF routines to deal with binary data */
-
                switch ( mod->sm_op ) {
                case LDAP_MOD_ADD:
                        fprintf( wfp, "add: %s\n", mod->sm_desc->ad_cname.bv_val );
@@ -105,8 +104,14 @@ shell_back_modify(
 
                if( mod->sm_values != NULL ) {
                        for ( i = 0; mod->sm_values[i].bv_val != NULL; i++ ) {
-                               fprintf( wfp, "%s: %s\n", mod->sm_desc->ad_cname.bv_val,
-                                       mod->sm_values[i].bv_val /* binary! */ );
+                               char *out = ldif_put( LDIF_PUT_VALUE,
+                                       mod->sm_desc->ad_cname.bv_val,
+                                       mod->sm_values[i].bv_val,
+                                       mod->sm_values[i].bv_len );
+                               if ( out ) {
+                                       fprintf( wfp, "%s", out );
+                                       ber_memfree( out );
+                               }
                        }
                }