aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2020-07-27 19:52:45 +0200
committerTom Smeding <tom.smeding@gmail.com>2020-07-27 21:28:39 +0200
commitf70ab0a787c42467beed3e29720508dbfd2d7447 (patch)
treea2016860efbb817b2c7275aaf8f04446f0d33f3c
parente9ddf0e9a82e12c3d4d384f9a8f321b3f409b997 (diff)
server: Enforce maximum message length
-rw-r--r--command.c7
1 files changed, 7 insertions, 0 deletions
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");