diff --git a/mongoose.c b/mongoose.c index 901c32d1..38c3f684 100644 --- a/mongoose.c +++ b/mongoose.c @@ -228,6 +228,7 @@ typedef int SOCKET; #define CGI_ENVIRONMENT_SIZE 4096 #define MAX_CGI_ENVIR_VARS 64 #define MG_BUF_LEN 8192 +#define MAX_REQUEST_SIZE 16384 #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) #ifdef _WIN32 @@ -427,7 +428,7 @@ struct socket { // NOTE(lsm): this enum shoulds be in sync with the config_options below. enum { CGI_EXTENSIONS, CGI_ENVIRONMENT, PUT_DELETE_PASSWORDS_FILE, CGI_INTERPRETER, - MAX_REQUEST_SIZE, PROTECT_URI, AUTHENTICATION_DOMAIN, SSI_EXTENSIONS, + PROTECT_URI, AUTHENTICATION_DOMAIN, SSI_EXTENSIONS, ACCESS_LOG_FILE, SSL_CHAIN_FILE, ENABLE_DIRECTORY_LISTING, ERROR_LOG_FILE, GLOBAL_PASSWORDS_FILE, INDEX_FILES, ENABLE_KEEP_ALIVE, ACCESS_CONTROL_LIST, EXTRA_MIME_TYPES, LISTENING_PORTS, DOCUMENT_ROOT, SSL_CERTIFICATE, @@ -440,7 +441,6 @@ static const char *config_options[] = { "E", "cgi_environment", NULL, "G", "put_delete_passwords_file", NULL, "I", "cgi_interpreter", NULL, - "M", "max_request_size", "16384", "P", "protect_uri", NULL, "R", "authentication_domain", "mydomain.com", "S", "ssi_pattern", "**.shtml$|**.shtm$", @@ -4182,13 +4182,12 @@ static int consume_socket(struct mg_context *ctx, struct socket *sp) { static void worker_thread(struct mg_context *ctx) { struct mg_connection *conn; - int buf_size = atoi(ctx->config[MAX_REQUEST_SIZE]); - conn = (struct mg_connection *) calloc(1, sizeof(*conn) + buf_size); + conn = (struct mg_connection *) calloc(1, sizeof(*conn) + MAX_REQUEST_SIZE); if (conn == NULL) { cry(fc(), "%s", "Cannot create new connection struct, OOM"); } else { - conn->buf_size = buf_size; + conn->buf_size = MAX_REQUEST_SIZE; conn->buf = (char *) (conn + 1); // Call consume_socket() even when ctx->stop_flag > 0, to let it signal