From: Pierangelo Masarati Date: Thu, 25 Apr 2002 19:23:37 +0000 (+0000) Subject: fix off-by-one bug; use s/sprintf/snprintf/ X-Git-Tag: OPENLDAP_REL_ENG_2_MP~147 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d2ee0b175821a345b97aedb047201d06faf06dfe;p=openldap fix off-by-one bug; use s/sprintf/snprintf/ --- 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",