From 3a01cfc90c7d52856882d65815f716a933c13657 Mon Sep 17 00:00:00 2001 From: Acts1631 Date: Fri, 21 Aug 2026 11:17:48 -0400 Subject: [PATCH] command/StickerCommands: validate find arguments After removing optional sort and window clauses, sticker find expects either four arguments or an operator/value pair for a total of six. With five arguments, the current code reads a nonexistent sixth element and may crash the daemon. Reject all other argument counts before accessing the optional value. --- src/command/StickerCommands.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/command/StickerCommands.cxx b/src/command/StickerCommands.cxx index 0061da15bb..ecafdd0bf1 100644 --- a/src/command/StickerCommands.cxx +++ b/src/command/StickerCommands.cxx @@ -524,7 +524,12 @@ handle_sticker(Client &client, Request args, Response &r) args.pop_back(); } - bool has_op = args.size() > 4; + if (args.size() != 4 && args.size() != 6) { + r.Error(ACK_ERROR_ARG, "bad request"); + return CommandResult::ERROR; + } + + const bool has_op = args.size() == 6; auto value = has_op ? args[5] : nullptr; StickerOperator op = StickerOperator::EXISTS; if (has_op) {