ITS#10414 Do not replace tool's provided buffer

This commit is contained in:
Ondřej Kuzník 2025-12-16 13:56:34 +00:00 committed by Quanah Gibson-Mount
parent 1668b5c432
commit 176680e824

View file

@ -8040,6 +8040,8 @@ config_tool_entry_put( BackendDB *be, Entry *e, struct berval *text )
strncmp( e->e_nname.bv_val + strncmp( e->e_nname.bv_val +
STRLENOF( "olcDatabase" ), "=frontend", STRLENOF( "olcDatabase" ), "=frontend",
STRLENOF( "=frontend" ))) { STRLENOF( "=frontend" ))) {
struct berval message = BER_BVC("autocreation of \"olcDatabase={-1}frontend\" failed");
memset( &ca, 0, sizeof(ConfigArgs)); memset( &ca, 0, sizeof(ConfigArgs));
ca.be = frontendDB; ca.be = frontendDB;
ca.bi = frontendDB->bd_info; ca.bi = frontendDB->bd_info;
@ -8061,8 +8063,7 @@ config_tool_entry_put( BackendDB *be, Entry *e, struct berval *text )
op->o_ndn = be->be_rootndn; op->o_ndn = be->be_rootndn;
rc = slap_add_opattrs(op, NULL, NULL, 0, 0); rc = slap_add_opattrs(op, NULL, NULL, 0, 0);
if ( rc != LDAP_SUCCESS ) { if ( rc != LDAP_SUCCESS ) {
text->bv_val = "autocreation of \"olcDatabase={-1}frontend\" failed"; ber_bvreplace( text, &message );
text->bv_len = STRLENOF("autocreation of \"olcDatabase={-1}frontend\" failed");
return NOID; return NOID;
} }
@ -8070,8 +8071,7 @@ config_tool_entry_put( BackendDB *be, Entry *e, struct berval *text )
bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) { bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) {
cfb->cb_got_ldif |= BCONFIG_GOT_FRONTEND; cfb->cb_got_ldif |= BCONFIG_GOT_FRONTEND;
} else { } else {
text->bv_val = "autocreation of \"olcDatabase={-1}frontend\" failed"; ber_bvreplace( text, &message );
text->bv_len = STRLENOF("autocreation of \"olcDatabase={-1}frontend\" failed");
return NOID; return NOID;
} }
} else { } else {
@ -8117,6 +8117,8 @@ config_tool_entry_put( BackendDB *be, Entry *e, struct berval *text )
strncmp( e->e_nname.bv_val + strncmp( e->e_nname.bv_val +
STRLENOF( "olcDatabase" ), "=config", STRLENOF( "olcDatabase" ), "=config",
STRLENOF( "=config" )) ) { STRLENOF( "=config" )) ) {
struct berval message = BER_BVC("autocreation of \"olcDatabase={0}config\" failed");
memset( &ca, 0, sizeof(ConfigArgs)); memset( &ca, 0, sizeof(ConfigArgs));
ca.be = LDAP_STAILQ_FIRST( &backendDB ); ca.be = LDAP_STAILQ_FIRST( &backendDB );
ca.bi = ca.be->bd_info; ca.bi = ca.be->bd_info;
@ -8139,16 +8141,14 @@ config_tool_entry_put( BackendDB *be, Entry *e, struct berval *text )
op->ora_e = ce; op->ora_e = ce;
rc = slap_add_opattrs(op, NULL, NULL, 0, 0); rc = slap_add_opattrs(op, NULL, NULL, 0, 0);
if ( rc != LDAP_SUCCESS ) { if ( rc != LDAP_SUCCESS ) {
text->bv_val = "autocreation of \"olcDatabase={0}config\" failed"; ber_bvreplace( text, &message );
text->bv_len = STRLENOF("autocreation of \"olcDatabase={0}config\" failed");
return NOID; return NOID;
} }
if (ce && bi && bi->bi_tool_entry_put && if (ce && bi && bi->bi_tool_entry_put &&
bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) { bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) {
cfb->cb_got_ldif |= BCONFIG_GOT_CONFIG; cfb->cb_got_ldif |= BCONFIG_GOT_CONFIG;
} else { } else {
text->bv_val = "autocreation of \"olcDatabase={0}config\" failed"; ber_bvreplace( text, &message );
text->bv_len = STRLENOF("autocreation of \"olcDatabase={0}config\" failed");
return NOID; return NOID;
} }
} else { } else {
@ -8160,7 +8160,9 @@ config_tool_entry_put( BackendDB *be, Entry *e, struct berval *text )
config_add_internal( cfb, e, &ca, NULL, NULL, NULL ) == 0 ) config_add_internal( cfb, e, &ca, NULL, NULL, NULL ) == 0 )
return bi->bi_tool_entry_put( &cfb->cb_db, e, text ); return bi->bi_tool_entry_put( &cfb->cb_db, e, text );
else { else {
ber_str2bv( ca.cr_msg, 0, 0, text ); struct berval bv;
ber_str2bv( ca.cr_msg, 0, 0, &bv );
ber_bvreplace( text, &bv );
return NOID; return NOID;
} }
} }