From bcb294620f3e7b56a30bf3c662f64d5c26c0c747 Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Wed, 10 Jul 2013 07:48:06 +0100 Subject: [PATCH] increased buffer for the ip address string from 20 to 50, to allow ipv6 addresses --- mongoose.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mongoose.c b/mongoose.c index 6252e06f..aca84578 100644 --- a/mongoose.c +++ b/mongoose.c @@ -289,6 +289,8 @@ typedef int socklen_t; #endif // NO_SOCKLEN_T #define _DARWIN_UNLIMITED_SELECT +#define IP_ADDR_STR_LEN 50 // IPv6 hex string is 46 chars + #if !defined(MSG_NOSIGNAL) #define MSG_NOSIGNAL 0 #endif @@ -610,7 +612,7 @@ static void cry(struct mg_connection *conn, // Print error message to the opened error log stream. static void cry(struct mg_connection *conn, const char *fmt, ...) { - char buf[MG_BUF_LEN], src_addr[20]; + char buf[MG_BUF_LEN], src_addr[IP_ADDR_STR_LEN]; va_list ap; FILE *fp; time_t timestamp; @@ -3230,7 +3232,7 @@ static void prepare_cgi_environment(struct mg_connection *conn, struct cgi_env_block *blk) { const char *s, *slash; struct vec var_vec; - char *p, src_addr[20]; + char *p, src_addr[IP_ADDR_STR_LEN]; int i; blk->len = blk->nvars = 0; @@ -4529,7 +4531,7 @@ static void log_header(const struct mg_connection *conn, const char *header, static void log_access(const struct mg_connection *conn) { const struct mg_request_info *ri; FILE *fp; - char date[64], src_addr[20]; + char date[64], src_addr[IP_ADDR_STR_LEN]; fp = conn->ctx->config[ACCESS_LOG_FILE] == NULL ? NULL : fopen(conn->ctx->config[ACCESS_LOG_FILE], "a+"); @@ -5101,7 +5103,7 @@ static int set_sock_timeout(SOCKET sock, int milliseconds) { static void accept_new_connection(const struct socket *listener, struct mg_context *ctx) { struct socket so; - char src_addr[20]; + char src_addr[IP_ADDR_STR_LEN]; socklen_t len = sizeof(so.rsa); int on = 1;