]> git.cameronkatri.com Git - cgit.git/commitdiff
Maŕk cgit_environment members const
authorLukas Fleischer <cgit@cryptocrack.de>
Mon, 1 Apr 2013 15:11:14 +0000 (17:11 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Mon, 8 Apr 2013 13:43:17 +0000 (15:43 +0200)
These reflect the values of environment variables and should never be
changed. Add another xstrdup() when we assign environment variables to
strings that are potentially non-constant.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
cgit.c
cgit.h

diff --git a/cgit.c b/cgit.c
index afafccee82f49639e191fd4c0c1a3d9b2aa027ee..d145f8ab415696ae98ff6ca5e602e18976ee125f 100644 (file)
--- a/cgit.c
+++ b/cgit.c
@@ -401,9 +401,9 @@ static void prepare_context(struct cgit_context *ctx)
        ctx->page.etag = NULL;
        memset(&ctx->cfg.mimetypes, 0, sizeof(struct string_list));
        if (ctx->env.script_name)
-               ctx->cfg.script_name = ctx->env.script_name;
+               ctx->cfg.script_name = xstrdup(ctx->env.script_name);
        if (ctx->env.query_string)
-               ctx->qry.raw = ctx->env.query_string;
+               ctx->qry.raw = xstrdup(ctx->env.query_string);
        if (!ctx->env.cgit_config)
                ctx->env.cgit_config = CGIT_CONFIG;
 }
diff --git a/cgit.h b/cgit.h
index ed5cf1487c7f728b0150510d79c30636790ea81a..081f669a8a5c438265cfd39b1443e0ebf876f3db 100644 (file)
--- a/cgit.h
+++ b/cgit.h
@@ -255,16 +255,16 @@ struct cgit_page {
 };
 
 struct cgit_environment {
-       char *cgit_config;
-       char *http_host;
-       char *https;
-       char *no_http;
-       char *path_info;
-       char *query_string;
-       char *request_method;
-       char *script_name;
-       char *server_name;
-       char *server_port;
+       const char *cgit_config;
+       const char *http_host;
+       const char *https;
+       const char *no_http;
+       const char *path_info;
+       const char *query_string;
+       const char *request_method;
+       const char *script_name;
+       const char *server_name;
+       const char *server_port;
 };
 
 struct cgit_context {