[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ldap
Subject:    PATCH for replicating binary data
From:       James Taylor <jtaylor () austin ! apc ! slb ! com>
Date:       1998-05-29 20:37:25
[Download RAW message or body]

Gordon Good was kind enough to point out the following patch
for replicating binary data correctly.  We came across the problem
when user certificates didn't show up correctly on replicas.
Anyhow the patch works like a charm so far.    

Hopefully the Critical Angle/Innosoft patch repository is
still active.

-- 
James Taylor                         e-mail: JMTaylor@slb.com
Austin Computing Services            phone:  1 512-331-3146
Schlumberger Technologies, APC            fax:    1 512-331-3059
P.O. Box 200015  Austin, Tx. USA
[Attachment #3 (message/rfc822)]

This is a multi-part message in MIME format.

James Taylor wrote:

> Mike,
>
> Thanks for the feedback.   Any chance you are storing digital
> certificates in your directory?  I've been trying to debug another
> problem with slurpd corrupting certificates.  I'm assuming the problem
> is in how slurpd stores binary data in the ldapMOD structure.  Since
> the update data from the slurpd.log can be successfully loaded on
> the replica using ldapmodify I'm using gdb to step through both slurpd
> and ldapmodify to see where they differ.  If I get to the root of
> the problem and a fix I'll send you a note.

James/Mike:

Try the attached patch.  There's a bug there, where binary values are being
copied using strdup().  If there happens to be a NULL byte in the value, then
strdup won't copy the entire value, and the rest of the bytes will be garbage.

I haven't tried to compile or test this, so some assembly may be required. The
fix is to allocate the new buffer explicitly and use memcpy() to copy the
value.

-Gordon

["diff.txt" (text/plain)]

*** re.c.orig	Tue May 26 09:00:53 1998
--- re.c	Tue May 26 09:03:07 1998
***************
*** 182,188 ****
  	    state |= GOT_TIME;
  	    break;
  	case T_DN:
! 	    re->re_dn = strdup( value );
  	    state |= GOT_DN;
  	    break;
  	default:
--- 182,189 ----
  	    state |= GOT_TIME;
  	    break;
  	case T_DN:
! 	    re->re_dn = calloc( 1, len + 1 );
! 	    memcpy( re->re_dn, value,  len );
  	    state |= GOT_DN;
  	    break;
  	default:
***************
*** 222,228 ****
  	    sizeof( Mi ) * ( nml + 2 ));
  	re->re_mods[ nml ].mi_type = strdup( type );
  	if ( value != NULL ) {
! 	    re->re_mods[ nml ].mi_val = strdup( value );
  	    re->re_mods[ nml ].mi_len = len;
  	} else {
  	    re->re_mods[ nml ].mi_val = NULL;
--- 223,230 ----
  	    sizeof( Mi ) * ( nml + 2 ));
  	re->re_mods[ nml ].mi_type = strdup( type );
  	if ( value != NULL ) {
! 	    re->re_mods[ nml ].mi_val = calloc( 1, len + 1 );
! 	    memcpy( re->re_mods[ nml ].mi_val, value, len );
  	    re->re_mods[ nml ].mi_len = len;
  	} else {
  	    re->re_mods[ nml ].mi_val = NULL;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic