]> git.cameronkatri.com Git - cgit.git/blobdiff - cgit.c
parsing: ban strncpy()
[cgit.git] / cgit.c
diff --git a/cgit.c b/cgit.c
index 223dfc8164b913d36a97534d48ab89fb4a650a70..6301b87c8ad3d29826e0fc585d6e494bcc9990bd 100644 (file)
--- a/cgit.c
+++ b/cgit.c
@@ -23,7 +23,7 @@ static void add_mimetype(const char *name, const char *value)
 {
        struct string_list_item *item;
 
-       item = string_list_insert(&ctx.cfg.mimetypes, xstrdup(name));
+       item = string_list_insert(&ctx.cfg.mimetypes, name);
        item->util = xstrdup(value);
 }
 
@@ -46,6 +46,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va
                repo->homepage = xstrdup(value);
        else if (!strcmp(name, "defbranch"))
                repo->defbranch = xstrdup(value);
+       else if (!strcmp(name, "extra-head-content"))
+               repo->extra_head_content = xstrdup(value);
        else if (!strcmp(name, "snapshots"))
                repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value);
        else if (!strcmp(name, "enable-commit-graph"))
@@ -414,7 +416,7 @@ static void prepare_context(void)
        ctx.page.modified = time(NULL);
        ctx.page.expires = ctx.page.modified;
        ctx.page.etag = NULL;
-       memset(&ctx.cfg.mimetypes, 0, sizeof(struct string_list));
+       string_list_init(&ctx.cfg.mimetypes, 1);
        if (ctx.env.script_name)
                ctx.cfg.script_name = xstrdup(ctx.env.script_name);
        if (ctx.env.query_string)
@@ -657,13 +659,13 @@ static inline void open_auth_filter(const char *function)
 static inline void authenticate_post(void)
 {
        char buffer[MAX_AUTHENTICATION_POST_BYTES];
-       unsigned int len;
+       ssize_t len;
 
        open_auth_filter("authenticate-post");
        len = ctx.env.content_length;
        if (len > MAX_AUTHENTICATION_POST_BYTES)
                len = MAX_AUTHENTICATION_POST_BYTES;
-       if (read(STDIN_FILENO, buffer, len) < 0)
+       if ((len = read(STDIN_FILENO, buffer, len)) < 0)
                die_errno("Could not read POST from stdin");
        if (write(STDOUT_FILENO, buffer, len) < 0)
                die_errno("Could not write POST to stdout");
@@ -797,6 +799,8 @@ static void print_repo(FILE *f, struct cgit_repo *repo)
        }
        if (repo->defbranch)
                fprintf(f, "repo.defbranch=%s\n", repo->defbranch);
+       if (repo->extra_head_content)
+               fprintf(f, "repo.extra-head-content=%s\n", repo->extra_head_content);
        if (repo->module_link)
                fprintf(f, "repo.module-link=%s\n", repo->module_link);
        if (repo->section)
@@ -826,6 +830,8 @@ static void print_repo(FILE *f, struct cgit_repo *repo)
                fprintf(f, "repo.snapshots=%s\n", tmp ? tmp : "");
                free(tmp);
        }
+       if (repo->snapshot_prefix)
+               fprintf(f, "repo.snapshot-prefix=%s\n", repo->snapshot_prefix);
        if (repo->max_stats != ctx.cfg.max_stats)
                fprintf(f, "repo.max-stats=%s\n",
                        cgit_find_stats_periodname(repo->max_stats));