aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2013-03-04ui-tree.c: Pass current revision to print_object()Lukas Fleischer1-3/+3
No longer access the global curr_rev variable in print_object(). This will make it easier to squash the curr_rev variable into a context structure without having to pass the context to the print_object() function. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2013-03-04ui-plain.c: Use a context structure in walk_tree()Lukas Fleischer1-13/+20
Do not misuse global variables to save the context. Instead, use the context pointer which was designed to share information between a read_tree_fn and the caller. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2013-03-04ui-plain.c: Do not access match variable in print_*()Lukas Fleischer1-12/+14
Move all code setting the match variable to walk_tree(). This allows for easily moving this variable into a context structure without having to pass the context to print_*(). Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2013-03-04ui-blob.c: Use a context structure in walk_tree()Lukas Fleischer1-16/+26
Do not misuse global variables to save the context. Instead, use the context pointer which was designed to share information between a read_tree_fn and the caller. This also prevents from potential misuse of the global pointers match_path and matched_sha1 after the referenced values have been overwritten on the stack. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2013-03-04ui-snapshot.c: Fill argv[0] with dummy.Jason A. Donenfeld1-0/+1
parse_archive_args does not pass PARSE_OPT_KEEP_ARGV0 to parse_args, which means the first argument will be discarded, as though it were a function being called from the command-line. Thus, we fill argv[0] with a dummy argument to prevent this from happening. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2013-03-04White space around control verbs.Jason A. Donenfeld16-42/+42
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2013-03-04Fix several whitespace errorsLukas Fleischer14-99/+99
* Remove whitespace at the end of lines. * Replace space indentation by tabs. * Add whitespace before/after several operators ("+", "-", "*", ...) * Add whitespace to assignments ("foo = bar;"). * Fix whitespace in parameter lists ("foobar(foo, bar, 42)"). Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2013-03-02Update git to v1.7.12.4John Keeping1-0/+0
No changes needed. Signed-off-by: John Keeping <john@keeping.me.uk>
2013-03-02Update git to v1.7.9.7John Keeping2-1/+1
resolve_ref() is renamed to resolve_ref_unsafe(). CGit's usage is safe. Signed-off-by: John Keeping <john@keeping.me.uk>
2013-03-02Update git to v1.7.8.6John Keeping1-0/+0
No changes required. Signed-off-by: John Keeping <john@keeping.me.uk>
2013-03-02Update git to v1.7.7.7John Keeping3-25/+38
This release changes the archive interface so that we now need to pass argv into write_archive(). Signed-off-by: John Keeping <john@keeping.me.uk>
2013-03-02Update git to v1.7.6.5John Keeping4-12/+43
struct pathspec is now used in more places. Signed-off-by: John Keeping <john@keeping.me.uk>
2013-03-02Update git to v1.7.5.4John Keeping3-6/+6
Some changes to diff options: - no_merges has become the more general max_parents - path restriction now uses struct pathspec Signed-off-by: John Keeping <john@keeping.me.uk>
2013-03-02Print submodule revision next to submodule linkstfn1-0/+1
2013-02-01Support unannotated tags in git-clone.Jason A. Donenfeld1-4/+2
Matthew McClintock reported that older unannotated tags were not correctly being cloned and did not appear in info/refs. Further investigation revealed some dubious prefix comparison code for determining whether or not to write refs in info/refs. After comparing it with git's own http-backend.c, it appears upstream does not use this prefix logic. OTOH, I don't know what the reasoning was when the prefix logic was introduced. It appears to me to just be buggy, though it's possible there are other reasons, and we'll have to revisit this commit. But for now, Works For Me. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Matthew McClintock <msm@freescale.com> Reported-by: Matthew McClintock <msm@freescale.com>
2013-02-01ssdiff: correctly manage tab expansionJulius Plenz1-2/+1
Previously, replace_tabs("foo\tbar") would become " foobar". Signed-off-by: Julius Plenz <plenz@cis.fu-berlin.de> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2013-02-01Make "owner" column on index page configurableFlorian Pritz4-7/+20
This is not really needed for personal sites where all repos belong to the same person. Since it is pretty useful for shared sites however, it should be configurable. Signed-off-by: Florian Pritz <bluewind@xinu.at> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2012-11-15man: fix up default value duplicationJason A. Donenfeld1-2/+2
2012-11-15CGIT-0.9.1v0.9.1Jason A. Donenfeld1-1/+1
Enhancements: - path-selected submodule links - intelligent default branch guessing - /etc/mime.types lookup - gitweb.* and cgit.* git-config support - case insensitive sorting and age sorting - commit, repository, and section sorting - bold currently viewed page in pagination - support BSDs in makefile Security: - CVE-2012-4465: heap-buffer overflow in parsing.c - CVE-2012-4548: syntax highlighting command injection Bug Fixes: - transition maintainer to Jason Donenfeld (zx2c4) - download git snapshot from github instead of Lars' old server - css fixes - stablization of tests - more compatible default highlight script - suppress gzip timestamp so that tarballs only use tar timestamps - treat ctags as target in makefile - do not let global variables override certain local repo settings - print ampersand as proper html entity - use placeholder for empty commit subject - format diff view for addition and removal of files - point links at correct blob from ssdiff Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2012-11-15man: show mime type default valueJason A. Donenfeld1-0/+1
2012-11-15ssdiff: point line links at exact blob by prepending "id="Julius Plenz1-2/+2
Previously, the id_str (i.e. the current or diffed-against commit's SHA1 ID) was simply concatenated to the URL. Now, prepend an "id=" string so that the links actually point to the right blobs and thus the exact lines. Signed-off-by: Julius Plenz <plenz@cis.fu-berlin.de> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2012-11-15Format git diff headers correctly when adding or removing files.Michael Halstead2-14/+22
Copying the output of cgit and using it in patches now works when adding files to or removing files from the repository. This is helpful for people who use cgit in their patch workflow.
2012-11-04Makefile: get snapshots from githubFerry Huberts1-2/+2
Github will have more bandwidth than Lars' server.
2012-11-01Makefile: remove tags fileJamie Couture1-1/+1
Remove tags file from working directory. Signed-off-by: Jamie Couture <jamie.couture@gmail.com>
2012-10-28ui-shared: use placeholder for empty commit subjectChristian Franke1-1/+4
Display a placeholder when creating links to commits with empty subjects. This avoids the creation of links of the form <a></a>.
2012-10-28syntax-highlighting.sh: Fix command injection.Jason A. Donenfeld1-2/+2
By not quoting the argument, an attacker with the ability to add files to the repository could pass arbitrary arguments to the highlight command, in particular, the --plug-in argument which can lead to arbitrary command execution. This patch adds simple argument quoting.
2012-10-18Fix man page typo.Jason A. Donenfeld1-2/+2
2012-10-17Makefile: Support OpenBSD just like FreeBSDJason A. Donenfeld1-2/+2
2012-10-17Makefile: support FreeBSD libiconv pathsJason A. Donenfeld1-0/+7
According to Dan Rue <drue@therub.org>, FreeBSD requires the lib paths to get libiconv from /usr/local.
2012-10-17tests: check for proper html entityJason A. Donenfeld1-1/+1
Since we're now properly writing ampersand literals as &amp; instead of as a plain &, we need to update the test accordingly. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2012-10-17ui-log: Add "commit-sort" option for controlling commit orderingTobias Bieniek8-6/+40
This makes it possible to use strict commit date ordering or strict topological ordering by passing the corresponding flags to "git log". Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2012-10-17ui-repolist: Add "section-sort" flag to control section sorting.Tobias Bieniek4-3/+13
Flag which, when set to "1", will sort the sections on the repository listing by name. Set this flag to "0" if the order in the cgitrc file should be preserved. Default value: "1". Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2012-10-17scan-tree: Unify gitweb.* and cgit.* settings into one config option.Jason A. Donenfeld5-58/+36
After some back and forth with Jamie and René, it looks like the git config semantics are going to be like this: - gitweb.category maps to the cgit repo config key "section" - gitweb.description maps to the cgit repo config key "desc" - gitweb.owner maps to the cgit repo config key "owner" - cgit.* maps to all cgit repo config keys This option can be enabled with "enable-git-config=1", and replaces all previous "enable-gitweb-*" config keys. The order of operations is as follows: - git config settings are applied in the order that they exist in the git config file - if the owner is not set from git config, get the owner using the usual getpwuid call - if the description is not set from git config, look inside the static $path/description file - if section-from-path=1, override whatever previous settings were inside of git config using the section-from-path logic - parse $path/cgitrc for local repo.* settings, that override all previous settings
2012-10-17ui: Remember to print ampersand as proper html entities.William Bell2-8/+8
2012-10-16ui-repolist: Rename section-sort to repository-sort.Jason A. Donenfeld4-7/+7
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2012-10-16repo_config: do not let globals override repo settingsTobias Bieniek1-3/+3
This makes it possible to activate the enable_commit_graph, enable_log_filecount, and enable_log_linecount for individual repositories, even if the global setting is "0" (default). The commit that introduced the broken behavior was e189344, and the commit message of that makes it clear that this wasn't the intended behavior. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2012-10-09README: times, they are a-changinJason A. Donenfeld1-1/+1
2012-10-09syntax-highlight: when the file has no extension, assume textFerry Huberts1-1/+4
There are 2 situations: 1- empty extension: assuming text is better than highlight producing no output because of a missing argument. 2- no extension at all: assuming text is better than setting the extension to the filename, which is what now happens. Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
2012-10-09ui-repolist: do not use agefile if it's date could not be parsedFerry Huberts1-2/+4
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
2012-10-09Revert "filters/syntax-highlighting.sh: work around highlight --force bug"Ferry Huberts1-17/+0
This reverts commit f50be7fda0a7ab57009169dd5905fcbab8eb5166. An update with the latest highlight landed in EPEL. This new version doesn't have the --force bug, so the workaround can now be removed. Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
2012-10-08Makefile: add tag target to generate ctagsJamie Couture1-1/+5
Signed-off-by: Jamie Couture <jamie.couture@gmail.com>
2012-10-08ui-repolist: Bold the currently viewed page.Jamie Couture2-4/+11
Signed-off-by: Jamie Couture <jamie.couture@gmail.com>
2012-10-02do not write outside heap bufferJim Meyering1-0/+2
* parsing.c (substr): Handle tail < head. This started when I noticed some cgit segfaults on savannah.gnu.org. Finding the offending URL/commit and then constructing a stand-alone reproducer were far more time-consuming than writing the actual patch. The problem arises with a commit like this, in which the user name part of the "Author" field is empty: $ git log -1 commit 6f3f41d73393278f3ede68a2cb1e7a2a23fa3421 Author: <T at h.or> Date: Mon Apr 23 22:29:16 2012 +0200 Here's what happens: (this is due to buf=malloc(0); strncpy (buf, head, -1); where "head" may point to plenty of attacker-specified non-NUL bytes, so we can overwrite a zero-length heap buffer with arbitrary data) Invalid write of size 1 at 0x4A09361: strncpy (mc_replace_strmem.c:463) by 0x408977: substr (parsing.c:61) by 0x4089EF: parse_user (parsing.c:73) by 0x408D10: cgit_parse_commit (parsing.c:153) by 0x40A540: cgit_mk_refinfo (shared.c:171) by 0x40A581: cgit_refs_cb (shared.c:181) by 0x43DEB3: do_for_each_ref (refs.c:690) by 0x41075E: cgit_print_branches (ui-refs.c:191) by 0x416EF2: cgit_print_summary (ui-summary.c:56) by 0x40780A: summary_fn (cmd.c:120) by 0x40667A: process_request (cgit.c:544) by 0x404078: cache_process (cache.c:322) Address 0x4c718d0 is 0 bytes after a block of size 0 alloc'd at 0x4A0884D: malloc (vg_replace_malloc.c:263) by 0x455C85: xmalloc (wrapper.c:35) by 0x40894C: substr (parsing.c:60) by 0x4089EF: parse_user (parsing.c:73) by 0x408D10: cgit_parse_commit (parsing.c:153) by 0x40A540: cgit_mk_refinfo (shared.c:171) by 0x40A581: cgit_refs_cb (shared.c:181) by 0x43DEB3: do_for_each_ref (refs.c:690) by 0x41075E: cgit_print_branches (ui-refs.c:191) by 0x416EF2: cgit_print_summary (ui-summary.c:56) by 0x40780A: summary_fn (cmd.c:120) by 0x40667A: process_request (cgit.c:544) Invalid write of size 1 at 0x4A09400: strncpy (mc_replace_strmem.c:463) by 0x408977: substr (parsing.c:61) by 0x4089EF: parse_user (parsing.c:73) by 0x408D10: cgit_parse_commit (parsing.c:153) by 0x40A540: cgit_mk_refinfo (shared.c:171) by 0x40A581: cgit_refs_cb (shared.c:181) by 0x43DEB3: do_for_each_ref (refs.c:690) by 0x41075E: cgit_print_branches (ui-refs.c:191) by 0x416EF2: cgit_print_summary (ui-summary.c:56) by 0x40780A: summary_fn (cmd.c:120) by 0x40667A: process_request (cgit.c:544) by 0x404078: cache_process (cache.c:322) Address 0x4c7192b is not stack'd, malloc'd or (recently) free'd Invalid write of size 1 at 0x4A0940E: strncpy (mc_replace_strmem.c:463) by 0x408977: substr (parsing.c:61) by 0x4089EF: parse_user (parsing.c:73) by 0x408D10: cgit_parse_commit (parsing.c:153) by 0x40A540: cgit_mk_refinfo (shared.c:171) by 0x40A581: cgit_refs_cb (shared.c:181) by 0x43DEB3: do_for_each_ref (refs.c:690) by 0x41075E: cgit_print_branches (ui-refs.c:191) by 0x416EF2: cgit_print_summary (ui-summary.c:56) by 0x40780A: summary_fn (cmd.c:120) by 0x40667A: process_request (cgit.c:544) by 0x404078: cache_process (cache.c:322) Address 0x4c7192d is not stack'd, malloc'd or (recently) free'd Process terminating with default action of signal 11 (SIGSEGV) Access not within mapped region at address 0x502F000 at 0x4A09400: strncpy (mc_replace_strmem.c:463) by 0x408977: substr (parsing.c:61) by 0x4089EF: parse_user (parsing.c:73) by 0x408D10: cgit_parse_commit (parsing.c:153) by 0x40A540: cgit_mk_refinfo (shared.c:171) by 0x40A581: cgit_refs_cb (shared.c:181) by 0x43DEB3: do_for_each_ref (refs.c:690) by 0x41075E: cgit_print_branches (ui-refs.c:191) by 0x416EF2: cgit_print_summary (ui-summary.c:56) by 0x40780A: summary_fn (cmd.c:120) by 0x40667A: process_request (cgit.c:544) by 0x404078: cache_process (cache.c:322) This happens when tail - head == -1 here: (parsing.c) char *substr(const char *head, const char *tail) { char *buf; buf = xmalloc(tail - head + 1); strncpy(buf, head, tail - head); buf[tail - head] = '\0'; return buf; } char *parse_user(char *t, char **name, char **email, unsigned long *date) { char *p = t; int mode = 1; while (p && *p) { if (mode == 1 && *p == '<') { *name = substr(t, p - 1); t = p; mode++; } else if (mode == 1 && *p == '\n') { The fix is to handle the case of (tail < head) before calling xmalloc, thus avoiding passing an invalid value to xmalloc. And here's the reproducer: It was tricky to reproduce, because git prohibits use of an empty "name" in a commit ID. To construct the offending commit, I had to resort to using "git hash-object". git init -q foo && ( cd foo && echo a > j && git add . && git ci -q --author='au <T at h.or>' -m. . && h=$(git cat-file commit HEAD|sed 's/au //' \ |git hash-object -t commit -w --stdin) && git co -q -b test $h && git br -q -D master && git br -q -m test master) git clone -q --bare foo foo.git cat <<EOF > in repo.url=foo.git repo.path=foo.git EOF CGIT_CONFIG=in QUERY_STRING=url=foo.git valgrind ./cgit The valgrind output is what you see above. AFAICS, this is not exploitable thanks (ironically) to the use of strncpy. Since that -1 translates to SIZE_MAX and this is strncpy, not only does it copy whatever is in "head" (up to first NUL), but it also writes SIZE_MAX - strlen(head) NUL bytes into the destination buffer, and that latter is guaranteed to evoke a segfault. Since cgit is single-threaded, AFAICS, there is no way that the buffer clobbering can be turned into an exploit.
2012-09-27ui-snapshot: pass -n to gzip, to suppress timestampJason A. Donenfeld1-8/+10
Since cgit snapshots of tags are often used for releases, we don't want the rarely used feature of the gzip compressor that includes an embedded timestamp into the archive, since this makes each tarball of the same (potentially signed) tag different. This commit refactors the archive handling code a bit so that each different format is able to run with an arbitrary argv for the filter.
2012-07-12Update copyright headers to have latest dates.Jason A. Donenfeld3-2/+3
2012-07-12ui-repolist: Case insensitive sorting and age sortJason A. Donenfeld4-5/+37
Add two options, one for doing the ordinary name sorts in a case-insensitive manner, and another for choosing to sort repos in each section by age instead of by name.
2012-07-12scan-tree: Support gitweb.category.Jason A. Donenfeld4-0/+14
Use gitweb.category from git config to determine repo's section, if option is enabled.
2012-07-12scan-tree: Support gitweb.description.Jason A. Donenfeld4-7/+28
Use gitweb.description instead of description file to determine description, if option is enabled.
2012-03-20css: only use div#cgitFerry Huberts1-4/+1
Don't bother with 'body' and 'div#cgit form', since everything is wrapped in 'div#cgit' already. Removing these two types makes embedding even easier. Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
2012-03-18Merge branch 'fh/mimetypes'Lars Hjemli4-1/+65