"vscode:/vscode.git/clone" did not exist on "68c75f248e9b0b4e4930372e2d09f3898de0a21c"
Commit a6e46274 authored by antirez's avatar antirez
Browse files

Close client connection and log the event when the client input buffer reaches 1GB.

parent 93babe4b
...@@ -862,6 +862,13 @@ void readQueryFromClient(aeEventLoop *el, int fd, void *privdata, int mask) { ...@@ -862,6 +862,13 @@ void readQueryFromClient(aeEventLoop *el, int fd, void *privdata, int mask) {
} else { } else {
return; return;
} }
if (sdslen(c->querybuf) > server.client_max_querybuf_len) {
sds ci = getClientInfoString(c);
redisLog(REDIS_WARNING,"Closing client that reached max query buffer length: %s", ci);
sdsfree(ci);
freeClient(c);
return;
}
processInputBuffer(c); processInputBuffer(c);
} }
......
...@@ -804,6 +804,7 @@ void initServerConfig() { ...@@ -804,6 +804,7 @@ void initServerConfig() {
server.dbnum = REDIS_DEFAULT_DBNUM; server.dbnum = REDIS_DEFAULT_DBNUM;
server.verbosity = REDIS_VERBOSE; server.verbosity = REDIS_VERBOSE;
server.maxidletime = REDIS_MAXIDLETIME; server.maxidletime = REDIS_MAXIDLETIME;
server.client_max_querybuf_len = REDIS_MAX_QUERYBUF_LEN;
server.saveparams = NULL; server.saveparams = NULL;
server.loading = 0; server.loading = 0;
server.logfile = NULL; /* NULL = log on standard output */ server.logfile = NULL; /* NULL = log on standard output */
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
/* Static server configuration */ /* Static server configuration */
#define REDIS_SERVERPORT 6379 /* TCP port */ #define REDIS_SERVERPORT 6379 /* TCP port */
#define REDIS_MAXIDLETIME 0 /* default client timeout: infinite */ #define REDIS_MAXIDLETIME 0 /* default client timeout: infinite */
#define REDIS_MAX_QUERYBUF_LEN (1024*1024*1024) /* 1GB max query buffer. */
#define REDIS_IOBUF_LEN (1024*16) #define REDIS_IOBUF_LEN (1024*16)
#define REDIS_LOADBUF_LEN 1024 #define REDIS_LOADBUF_LEN 1024
#define REDIS_DEFAULT_DBNUM 16 #define REDIS_DEFAULT_DBNUM 16
...@@ -418,6 +419,7 @@ struct redisServer { ...@@ -418,6 +419,7 @@ struct redisServer {
/* Configuration */ /* Configuration */
int verbosity; int verbosity;
int maxidletime; int maxidletime;
size_t client_max_querybuf_len;
int dbnum; int dbnum;
int daemonize; int daemonize;
int appendonly; int appendonly;
...@@ -700,6 +702,7 @@ void addReplyMultiBulkLen(redisClient *c, long length); ...@@ -700,6 +702,7 @@ void addReplyMultiBulkLen(redisClient *c, long length);
void *dupClientReplyValue(void *o); void *dupClientReplyValue(void *o);
void getClientsMaxBuffers(unsigned long *longest_output_list, void getClientsMaxBuffers(unsigned long *longest_output_list,
unsigned long *biggest_input_buffer); unsigned long *biggest_input_buffer);
sds getClientInfoString(redisClient *client);
void rewriteClientCommandVector(redisClient *c, int argc, ...); void rewriteClientCommandVector(redisClient *c, int argc, ...);
#ifdef __GNUC__ #ifdef __GNUC__
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment