Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions inc/tagline.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,43 @@ typedef Tagline_V10_32 Tagline32;
#define TAGLINE_DB_CURRENT_VERSION 10
#define TAGLINE_DB_SUPPORTED_VERSION "10"

/*
* TAGLINE_MAX_LEN -- hard cap on tagline text length, in bytes.
*
* This is not an arbitrary knob. The tightest constraint is not storage
* or the inbound PRIVMSG the operator sends to OperServ (servers use a
* nick-only prefix when propagating client traffic, per RFC 1459 s.2.3
* and bahamut convention, which leaves ample room). It is the *outbound*
* broadcast produced by send_globops() in handle_tagline() and
* tagline_show(), which bahamut turns into a NOTICE to every +g operator
* (see src/send.c:send_globops in bahamut):
*
* :<server> NOTICE <destnick> :*** Global -- \2<caller>\2
* (through \2<oper>\2) added the following tagline: <text>\r\n
*
* The IRC protocol caps a single line at 512 bytes including the
* trailing CR-LF (RFC 1459 s.2.3.1). Worst-case byte budget:
*
* `:<server>` (HOSTMAX=63) + ` NOTICE ` (8) + `<destnick>`
* (NICKMAX=32) + ` :*** Global -- ` (16) + bold markers + `<caller>`
* (NICKMAX=32) + ` (through ` (10) + bold markers + `<oper>`
* (NICKMAX=32) + `) added the following tagline: ` (31) + <text>
* + `\r\n` (2) ~= 230 + text
*
* So the theoretical worst case caps text at ~280, though realistic
* Azzurra params (server name ~21, operator nicks ~8-12) leave comfortable
* headroom. 350 keeps us well clear of truncation across both realistic
* and near-worst-case combinations without pushing the limit.
*
* Before raising this value, re-derive both envelopes (services-side
* send_globops() and bahamut's send_globops() NOTICE wrapper) against
* every call site that embeds a tagline. Blind increases cause silent
* truncation at the receiving server with no feedback to the originating
* operator -- the stored tagline is fine, but the GLOBOPS confirmation
* message seen by +g opers gets its tail cut.
*/
#define TAGLINE_MAX_LEN 350


/*********************************************************
* Global variables *
Expand Down
6 changes: 3 additions & 3 deletions src/tagline.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ void handle_tagline(CSTR source, User *callerUser, ServiceCommandData *data) {
return;
}

if ((len = str_len(text)) > 260) {
if ((len = str_len(text)) > TAGLINE_MAX_LEN) {

send_notice_to_user(s_OperServ, callerUser, "The maximum length for a tagline is 260 characters. Your tagline has %d.", len);
send_notice_to_user(s_OperServ, callerUser, "The maximum length for a tagline is %d characters. Your tagline has %d.", TAGLINE_MAX_LEN, len);
return;
}

Expand Down Expand Up @@ -417,7 +417,7 @@ void handle_tagline(CSTR source, User *callerUser, ServiceCommandData *data) {
return;
}

if (str_len(text) > 260) {
if (str_len(text) > TAGLINE_MAX_LEN) {

send_notice_to_user(s_OperServ, callerUser, "Tagline not found.");
return;
Expand Down
Loading