diff --git a/inc/tagline.h b/inc/tagline.h index e19d6a9..ff0e8a7 100644 --- a/inc/tagline.h +++ b/inc/tagline.h @@ -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): + * + * : NOTICE :*** Global -- \2\2 + * (through \2\2) added the following tagline: \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: + * + * `:` (HOSTMAX=63) + ` NOTICE ` (8) + `` + * (NICKMAX=32) + ` :*** Global -- ` (16) + bold markers + `` + * (NICKMAX=32) + ` (through ` (10) + bold markers + `` + * (NICKMAX=32) + `) added the following tagline: ` (31) + + * + `\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 * diff --git a/src/tagline.c b/src/tagline.c index ef5d824..398c0df 100644 --- a/src/tagline.c +++ b/src/tagline.c @@ -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; } @@ -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;