From f70ab0a787c42467beed3e29720508dbfd2d7447 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 27 Jul 2020 19:52:45 +0200 Subject: server: Enforce maximum message length --- command.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/command.c b/command.c index 4ace92b..1cd8619 100644 --- a/command.c +++ b/command.c @@ -16,6 +16,9 @@ #include "util.h" +#define MAX_MESSAGE_LEN 10000 + + struct cmd_retval{ bool socket_close; bool memzero; @@ -229,6 +232,10 @@ static struct cmd_retval cmd_send(struct conn_data *data,const char *tag,const c userdata_mark_active(data->userid,data->fd,true); const char *roomname=args[0]; const char *message=args[1]; + if(strlen(message)>MAX_MESSAGE_LEN){ + net_send_error(data->fd,tag,"Message too long"); + return RET_OK; + } i64 roomid=db_find_room(roomname); if(roomid==-1){ net_send_error(data->fd,tag,"Room not found"); -- cgit v1.2.3-70-g09d2