From d2ee0b175821a345b97aedb047201d06faf06dfe Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Thu, 25 Apr 2002 19:23:37 +0000 Subject: [PATCH] fix off-by-one bug; use s/sprintf/snprintf/ --- servers/slurpd/ldap_op.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/servers/slurpd/ldap_op.c b/servers/slurpd/ldap_op.c index 2d63daefaf..baa1f0fce2 100644 --- a/servers/slurpd/ldap_op.c +++ b/servers/slurpd/ldap_op.c @@ -563,10 +563,13 @@ op_ldap_modrdn( if ( ldap_debug & LDAP_DEBUG_ARGS ) { char buf[ 256 ]; char *buf2; - sprintf( buf, "%s:%d", ri->ri_hostname, ri->ri_port ); - buf2 = (char *) ch_malloc( strlen( re->re_dn ) + strlen( mi->mi_val ) - + 10 ); - sprintf( buf2, "(\"%s\" -> \"%s\")", re->re_dn, mi->mi_val ); + int buf2len = strlen( re->re_dn ) + strlen( mi->mi_val ) + 11; + + snprintf( buf, sizeof(buf), "%s:%d", ri->ri_hostname, ri->ri_port ); + + buf2 = (char *) ch_malloc( buf2len ); + snprintf( buf2, buf2len, "(\"%s\" -> \"%s\")", re->re_dn, mi->mi_val ); + #ifdef NEW_LOGGING LDAP_LOG (( "ldap_op", LDAP_LEVEL_ARGS, "op_ldap_modrdn: replica %s - modify rdn %s (flag: %d)\n", -- 2.39.5