[rtems commit] mghttpd/mongoose: Fix string truncation warning

Sebastian Huber sebh at rtems.org
Sat Oct 10 13:16:00 UTC 2020


Module:    rtems
Branch:    master
Commit:    c8c1426c682325586e20c763dee3ec71c9ca4bff
Changeset: http://git.rtems.org/rtems/commit/?id=c8c1426c682325586e20c763dee3ec71c9ca4bff

Author:    Frank Kühndel <frank.kuehndel at embedded-brains.de>
Date:      Tue Oct  6 15:01:31 2020 +0200

mghttpd/mongoose: Fix string truncation warning

This fixes the compiler warning below.

../../../cpukit/mghttpd/mongoose.c:1919:45: warning:
'.gz' directive output may be truncated writing 3 bytes into a region
of size between 1 and 255 [-Wformat-truncation=]

---

 cpukit/mghttpd/mongoose.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cpukit/mghttpd/mongoose.c b/cpukit/mghttpd/mongoose.c
index fb2bce7..0736c83 100644
--- a/cpukit/mghttpd/mongoose.c
+++ b/cpukit/mghttpd/mongoose.c
@@ -1887,7 +1887,7 @@ static void convert_uri_to_file_name(struct mg_connection *conn, char *buf,
         *root = conn->ctx->config[DOCUMENT_ROOT];
   char *p;
   int match_len;
-  char gz_path[PATH_MAX];
+  char gz_path[PATH_MAX + 3];
   char const* accept_encoding;
 
   // Using buf_len - 1 because memmove() for PATH_INFO may shift part
@@ -3021,7 +3021,7 @@ static void handle_file_request(struct mg_connection *conn, const char *path,
   int64_t cl, r1, r2;
   struct vec mime_vec;
   int n;
-  char gz_path[PATH_MAX];
+  char gz_path[PATH_MAX + 3];
   char const* encoding = "";
 
   get_mime_type(conn->ctx, path, &mime_vec);



More information about the vc mailing list