…prebuilt SQL fragments
Two defects found while reviewing the port of sbpp#1492.
1. Truncation guards were dead code.
Database.Format / SQL_FormatQuery goes through InternalFormat -> atcprintf,
which starts with llen = maxlen - 1 and returns (maxlen - llen - 1). The
return value is therefore capped at maxlength - 1 and can never be >=
sizeof(buffer), so every "if (db.Format(...) >= sizeof(buf))" check (and the
inverted "< sizeof(buf)" variants in VerifyBan) could never trigger. All 34
guards in sbpp_main.sp and sbpp_comms.sp now compare against
sizeof(buf) - 1 (and iQueryLen - 1 for the dynamically sized report query),
which is the standard truncation test.
2. sbpp_comms.sp InsertTempBlock escaped its own SQL.
The queue2 INSERT passed the prebuilt sQueryMute/sQueryGag value tuples
through %s, so SQLiteDB.Format escaped the single quotes inside them and
produced a syntactically invalid statement, silently dropping temp comm
blocks queued while the main database was down. Switched to %!s%!s%!s to
match the equivalent statement in SavePunishment.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Rushaway <rushaway@hotmail.fr>
Description
Port of upstream sbpp/sourcebans-pp#1492 to the srcdslab fork.
Updated files:
sbpp_main.spsbpp_comms.spKey changes:
Escape+Formatpatterns withDB.Format/SQLiteDB.Format.%!sfor internal SQL identifiers/fragments,%sfor user/runtime input.DB.Query, all reported viaLogError.DataPackobjects are now allocated only after successful query formatting; addedCleanupBanDataPackhelper.Fork-specific adaptation
The srcdslab fork carries an extra
admin_namecolumn (andIFNULL((SELECT user FROM %!s_admins ...))subquery) in the_bansand_commsINSERT statements. These were preserved through the merge and converted to the newDB.Format/%!scontract, including new truncation guards on the added admin-name subqueries.Notes
spcompavailable); relies on theplugin-buildCI workflow.🤖 Generated with Claude Code