about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorLukas Fleischer2013-04-01 17:11:14 +0200
committerJason A. Donenfeld2013-04-08 15:43:17 +0200
commit3a8432437934a0a95f2618b534b1f5b3494d6b18 (patch)
tree6e7dd26d45c4f10c60dc762a11071f1787a79443
parentReturn const char * in cgit_{httpscheme, hosturl, rooturl}() (diff)
downloadcgit-3a8432437934a0a95f2618b534b1f5b3494d6b18.tar.gz
cgit-3a8432437934a0a95f2618b534b1f5b3494d6b18.zip
Maŕk cgit_environment members const
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>
-rw-r--r--cgit.c4
-rw-r--r--cgit.h20
2 files changed, 12 insertions, 12 deletions
diff --git a/cgit.c b/cgit.c index afafcce..d145f8a 100644 --- a/cgit.c +++ b/cgit.c
@@ -401,9 +401,9 @@ static void prepare_context(struct cgit_context *ctx)
401 ctx->page.etag = NULL; 401 ctx->page.etag = NULL;
402 memset(&ctx->cfg.mimetypes, 0, sizeof(struct string_list)); 402 memset(&ctx->cfg.mimetypes, 0, sizeof(struct string_list));
403 if (ctx->env.script_name) 403 if (ctx->env.script_name)
404 ctx->cfg.script_name = ctx->env.script_name; 404 ctx->cfg.script_name = xstrdup(ctx->env.script_name);
405 if (ctx->env.query_string) 405 if (ctx->env.query_string)
406 ctx->qry.raw = ctx->env.query_string; 406 ctx->qry.raw = xstrdup(ctx->env.query_string);
407 if (!ctx->env.cgit_config) 407 if (!ctx->env.cgit_config)
408 ctx->env.cgit_config = CGIT_CONFIG; 408 ctx->env.cgit_config = CGIT_CONFIG;
409} 409}
diff --git a/cgit.h b/cgit.h index ed5cf14..081f669 100644 --- a/cgit.h +++ b/cgit.h
@@ -255,16 +255,16 @@ struct cgit_page {
255}; 255};
256 256
257struct cgit_environment { 257struct cgit_environment {
258 char *cgit_config; 258 const char *cgit_config;
259 char *http_host; 259 const char *http_host;
260 char *https; 260 const char *https;
261 char *no_http; 261 const char *no_http;
262 char *path_info; 262 const char *path_info;
263 char *query_string; 263 const char *query_string;
264 char *request_method; 264 const char *request_method;
265 char *script_name; 265 const char *script_name;
266 char *server_name; 266 const char *server_name;
267 char *server_port; 267 const char *server_port;
268}; 268};
269 269
270struct cgit_context { 270struct cgit_context {