]> granicus.if.org Git - cgit/log
cgit
11 years agocgit_print_commit(): Free tmp variable
Lukas Fleischer [Mon, 4 Mar 2013 12:25:37 +0000 (13:25 +0100)]
cgit_print_commit(): Free tmp variable

Fixes following memory leak seen with "PATH_INFO=/cgit/commit/":

    ==16894== 7 bytes in 1 blocks are definitely lost in loss record 4 of 92
    ==16894==    at 0x4C2C04B: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==16894==    by 0x56F2DF1: strdup (in /usr/lib/libc-2.17.so)
    ==16894==    by 0x46CAC8: xstrdup (wrapper.c:35)
    ==16894==    by 0x40CD6F: cgit_print_commit (ui-commit.c:70)
    ==16894==    by 0x407B06: commit_fn (cmd.c:54)
    ==16894==    by 0x405E16: process_request (cgit.c:574)
    ==16894==    by 0x4074C8: cache_process (cache.c:322)
    ==16894==    by 0x406C4F: main (cgit.c:872)

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agocgit_print_tree(): Free curr_rev after usage
Lukas Fleischer [Mon, 4 Mar 2013 12:25:36 +0000 (13:25 +0100)]
cgit_print_tree(): Free curr_rev after usage

Fixes following memory leak seen with "PATH_INFO=/cgit/tree/":

    ==15715== 7 bytes in 1 blocks are definitely lost in loss record 4 of 51
    ==15715==    at 0x4C2C04B: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==15715==    by 0x56F2DF1: strdup (in /usr/lib/libc-2.17.so)
    ==15715==    by 0x46CAA8: xstrdup (wrapper.c:35)
    ==15715==    by 0x418A4C: cgit_print_tree (ui-tree.c:274)
    ==15715==    by 0x407D91: tree_fn (cmd.c:131)
    ==15715==    by 0x405E16: process_request (cgit.c:574)
    ==15715==    by 0x4074C8: cache_process (cache.c:322)
    ==15715==    by 0x406C4F: main (cgit.c:872)

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agofind_default_branch(): Free refmatch after usage
Lukas Fleischer [Mon, 4 Mar 2013 12:25:35 +0000 (13:25 +0100)]
find_default_branch(): Free refmatch after usage

Fixes following memory leak seen with "PATH_INFO=/cgit/refs/":

    ==13408== 7 bytes in 1 blocks are definitely lost in loss record 4 of 52
    ==13408==    at 0x4C2C04B: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==13408==    by 0x56F2DF1: strdup (in /usr/lib/libc-2.17.so)
    ==13408==    by 0x46CA78: xstrdup (wrapper.c:35)
    ==13408==    by 0x405840: find_current_ref (cgit.c:426)
    ==13408==    by 0x44BE5A: do_one_ref (refs.c:527)
    ==13408==    by 0x44D3E0: do_for_each_ref_in_dir (refs.c:553)
    ==13408==    by 0x44D85A: do_for_each_ref (refs.c:1298)
    ==13408==    by 0x405889: find_default_branch (cgit.c:438)
    ==13408==    by 0x405AC4: prepare_repo_cmd (cgit.c:490)
    ==13408==    by 0x405D97: process_request (cgit.c:557)
    ==13408==    by 0x407490: cache_process (cache.c:322)
    ==13408==    by 0x406C18: main (cgit.c:864)

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoprint_tag_downloads(): Free ref variable
Lukas Fleischer [Mon, 4 Mar 2013 12:25:34 +0000 (13:25 +0100)]
print_tag_downloads(): Free ref variable

Make sure the ref variable is freed if we build a
"$basename-$version"-style ref.

This fixes following memory leak seen with "PATH_INFO=/cgit/refs/":

    ==8784== 323 bytes in 29 blocks are definitely lost in loss record 41 of 53
    ==8784==    at 0x4C2C04B: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==8784==    by 0x56F2DF1: strdup (in /usr/lib/libc-2.17.so)
    ==8784==    by 0x46CA28: xstrdup (wrapper.c:35)
    ==8784==    by 0x410DA6: print_tag_downloads (ui-refs.c:115)
    ==8784==    by 0x410F02: print_tag (ui-refs.c:141)
    ==8784==    by 0x41128B: cgit_print_tags (ui-refs.c:230)
    ==8784==    by 0x41134D: cgit_print_refs (ui-refs.c:250)
    ==8784==    by 0x407C85: refs_fn (cmd.c:105)
    ==8784==    by 0x405DDF: process_request (cgit.c:566)
    ==8784==    by 0x407490: cache_process (cache.c:322)
    ==8784==    by 0x406C18: main (cgit.c:864)

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoFree reflists after usage
Lukas Fleischer [Mon, 4 Mar 2013 12:25:33 +0000 (13:25 +0100)]
Free reflists after usage

Free reflists in cgit_print_branches() and in cgit_print_tags() before
returning reflist structures to the stack.

This fixes following memory leaks seen with "PATH_INFO=/cgit/refs/":

    ==5710== 1,312 (32 direct, 1,280 indirect) bytes in 1 blocks are definitely lost in loss record 63 of 71
    ==5710==    at 0x4C2C04B: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==5710==    by 0x4C2C2FF: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==5710==    by 0x46CA9B: xrealloc (wrapper.c:100)
    ==5710==    by 0x40AAA6: cgit_add_ref (shared.c:156)
    ==5710==    by 0x40ABC4: cgit_refs_cb (shared.c:186)
    ==5710==    by 0x44BCBA: do_one_ref (refs.c:527)
    ==5710==    by 0x44D240: do_for_each_ref_in_dir (refs.c:553)
    ==5710==    by 0x44D6BA: do_for_each_ref (refs.c:1298)
    ==5710==    by 0x410FE2: cgit_print_branches (ui-refs.c:191)
    ==5710==    by 0x4111E9: cgit_print_refs (ui-refs.c:244)
    ==5710==    by 0x407C85: refs_fn (cmd.c:105)
    ==5710==    by 0x405DDF: process_request (cgit.c:566)
    ==5710==
    ==5710== 6,846 (256 direct, 6,590 indirect) bytes in 1 blocks are definitely lost in loss record 68 of 71
    ==5710==    at 0x4C2C25E: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==5710==    by 0x46CA9B: xrealloc (wrapper.c:100)
    ==5710==    by 0x40AAA6: cgit_add_ref (shared.c:156)
    ==5710==    by 0x40ABC4: cgit_refs_cb (shared.c:186)
    ==5710==    by 0x44BCBA: do_one_ref (refs.c:527)
    ==5710==    by 0x44D240: do_for_each_ref_in_dir (refs.c:553)
    ==5710==    by 0x44D6EC: do_for_each_ref (refs.c:1288)
    ==5710==    by 0x4110D5: cgit_print_tags (ui-refs.c:218)
    ==5710==    by 0x4111FD: cgit_print_refs (ui-refs.c:246)
    ==5710==    by 0x407C85: refs_fn (cmd.c:105)
    ==5710==    by 0x405DDF: process_request (cgit.c:566)
    ==5710==    by 0x407490: cache_process (cache.c:322)

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoui-shared.c: Remove unused function print_archive_ref()
Lukas Fleischer [Mon, 4 Mar 2013 07:52:35 +0000 (08:52 +0100)]
ui-shared.c: Remove unused function print_archive_ref()

This is no longer used as of commit f135569b.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoui-shared.c: Remove unused function cgit_currurl()
Lukas Fleischer [Mon, 4 Mar 2013 07:52:34 +0000 (08:52 +0100)]
ui-shared.c: Remove unused function cgit_currurl()

This is no longer used as of commit 0c8e184e.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoMark several functions/variables static
Lukas Fleischer [Mon, 4 Mar 2013 07:52:33 +0000 (08:52 +0100)]
Mark several functions/variables static

Spotted by parsing the output of `gcc -Wmissing-prototypes [...]`.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agot0107-snapshot: add tests for ZIP archives
John Keeping [Mon, 4 Mar 2013 21:58:51 +0000 (21:58 +0000)]
t0107-snapshot: add tests for ZIP archives

Signed-off-by: John Keeping <john@keeping.me.uk>
11 years agotests: make whitespace consistent
John Keeping [Mon, 4 Mar 2013 21:58:50 +0000 (21:58 +0000)]
tests: make whitespace consistent

Signed-off-by: John Keeping <john@keeping.me.uk>
11 years agotests: "grep -e" is not portable to all platforms
John Keeping [Mon, 4 Mar 2013 21:58:49 +0000 (21:58 +0000)]
tests: "grep -e" is not portable to all platforms

The "-e" option to grep is not needed unless specifying more than one
pattern, which we don't do.  Remove it to avoid restricting the tests on
platforms that do not have a grep that recognises "-e".

Signed-off-by: John Keeping <john@keeping.me.uk>
11 years agoMakefile: Disable gettext in the Git submodule
Lukas Fleischer [Mon, 4 Mar 2013 08:18:38 +0000 (09:18 +0100)]
Makefile: Disable gettext in the Git submodule

Newer libgit versions depend on the libintl library. However, we
currently do not link against libintl which breaks compilation under
OpenBSD:

    git/libgit.a(commit.o)(.text+0x1d1b): In function `lookup_commit_or_die':
    git/gettext.h:47: undefined reference to `libintl_gettext'
    [...]

Since we do not support i18n in cgit, just disable gettext in the Git
submodule to fix this.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoMakefile: improve dependency generation
Jamie Couture [Sat, 17 Nov 2012 18:02:17 +0000 (13:02 -0500)]
Makefile: improve dependency generation

Makefile target generation would always be included for any makefile
target that was not clean.  Only care to include the '.deps' directory
when building cgit, rather than generating and including dependencies
when calling other makefile targets.

Heavily borrowed from git's Makefile, but without definitions to test
for the compiler's header dependency feature.  Previous Makefile
implementation never checked for this compiler feature anyway.

  - Removed makecmdgoal 'clean' check
  - Grouped like .PHONY target definitions
  - Place build dependency targets under .SUFFIXES
  - Re-arranged location of library inclusion definitions
  - Use google code mirror instead of github

Signed-off-by: Jamie Couture <jamie.couture@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11 years agocgit.c: Remove parameter from guess_defbranch()
Lukas Fleischer [Sun, 3 Mar 2013 21:42:35 +0000 (22:42 +0100)]
cgit.c: Remove parameter from guess_defbranch()

We use resolve_ref() since commit 8d7c2ec2, so this is no longer needed.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoui-tree.c: Use a context structure in walk_tree()
Lukas Fleischer [Sun, 3 Mar 2013 16:22:30 +0000 (17:22 +0100)]
ui-tree.c: Use a context structure in walk_tree()

Use the context pointer to pass context information instead of misusing
global variables, as we already did in "ui-blob.c" and in "ui-plain.c".

In addition to the fixes to walk_tree(), pass the same structure to
ls_tree() and ls_item() which is read_tree_recursive()-based as well.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoui-tree.c: Drop the header variable
Lukas Fleischer [Sun, 3 Mar 2013 15:55:21 +0000 (16:55 +0100)]
ui-tree.c: Drop the header variable

Instead, use the value of the state variable to determine whether the
footer needs to be drawn.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoui-tree.c: Declare the state variable globally
Lukas Fleischer [Sun, 3 Mar 2013 15:49:47 +0000 (16:49 +0100)]
ui-tree.c: Declare the state variable globally

This allows for removing the header variable in a following patch. We
can use the state variable to check whether the tail needs to be printed
instead.

Note that the state variable will be moved into a context structure
later.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
11 years agoui-tree.c: Pass current revision to print_object()
Lukas Fleischer [Sun, 3 Mar 2013 15:45:14 +0000 (16:45 +0100)]
ui-tree.c: Pass current revision to print_object()

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>
11 years agoui-plain.c: Use a context structure in walk_tree()
Lukas Fleischer [Sun, 3 Mar 2013 16:27:54 +0000 (17:27 +0100)]
ui-plain.c: Use a context structure in walk_tree()

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>
11 years agoui-plain.c: Do not access match variable in print_*()
Lukas Fleischer [Sun, 3 Mar 2013 16:10:19 +0000 (17:10 +0100)]
ui-plain.c: Do not access match variable in print_*()

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>
11 years agoui-blob.c: Use a context structure in walk_tree()
Lukas Fleischer [Sun, 3 Mar 2013 16:27:46 +0000 (17:27 +0100)]
ui-blob.c: Use a context structure in walk_tree()

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>
11 years agoui-snapshot.c: Fill argv[0] with dummy.
Jason A. Donenfeld [Mon, 4 Mar 2013 04:41:53 +0000 (23:41 -0500)]
ui-snapshot.c: Fill argv[0] with dummy.

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>
11 years agoWhite space around control verbs.
Jason A. Donenfeld [Mon, 4 Mar 2013 04:21:33 +0000 (23:21 -0500)]
White space around control verbs.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
11 years agoFix several whitespace errors
Lukas Fleischer [Sun, 3 Mar 2013 15:04:29 +0000 (16:04 +0100)]
Fix several whitespace errors

* 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>
11 years agoUpdate git to v1.7.12.4
John Keeping [Sat, 2 Mar 2013 12:32:15 +0000 (12:32 +0000)]
Update git to v1.7.12.4

No changes needed.

Signed-off-by: John Keeping <john@keeping.me.uk>
11 years agoUpdate git to v1.7.9.7
John Keeping [Sat, 2 Mar 2013 12:32:14 +0000 (12:32 +0000)]
Update git to v1.7.9.7

resolve_ref() is renamed to resolve_ref_unsafe().  CGit's usage is safe.

Signed-off-by: John Keeping <john@keeping.me.uk>
11 years agoUpdate git to v1.7.8.6
John Keeping [Sat, 2 Mar 2013 12:32:13 +0000 (12:32 +0000)]
Update git to v1.7.8.6

No changes required.

Signed-off-by: John Keeping <john@keeping.me.uk>
11 years agoUpdate git to v1.7.7.7
John Keeping [Sat, 2 Mar 2013 12:32:12 +0000 (12:32 +0000)]
Update git to v1.7.7.7

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>
11 years agoUpdate git to v1.7.6.5
John Keeping [Sat, 2 Mar 2013 12:32:11 +0000 (12:32 +0000)]
Update git to v1.7.6.5

struct pathspec is now used in more places.

Signed-off-by: John Keeping <john@keeping.me.uk>
11 years agoUpdate git to v1.7.5.4
John Keeping [Sat, 2 Mar 2013 12:32:10 +0000 (12:32 +0000)]
Update git to v1.7.5.4

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>
11 years agoPrint submodule revision next to submodule link
stfn [Wed, 27 Feb 2013 18:47:17 +0000 (19:47 +0100)]
Print submodule revision next to submodule link

11 years agoSupport unannotated tags in git-clone.
Jason A. Donenfeld [Fri, 1 Feb 2013 20:08:51 +0000 (21:08 +0100)]
Support unannotated tags in git-clone.

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>
11 years agossdiff: correctly manage tab expansion
Julius Plenz [Thu, 15 Nov 2012 16:35:06 +0000 (17:35 +0100)]
ssdiff: correctly manage tab expansion

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>
11 years agoMake "owner" column on index page configurable
Florian Pritz [Fri, 1 Feb 2013 09:59:13 +0000 (10:59 +0100)]
Make "owner" column on index page configurable

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>
12 years agoman: fix up default value duplication
Jason A. Donenfeld [Thu, 15 Nov 2012 16:21:47 +0000 (17:21 +0100)]
man: fix up default value duplication

12 years agoCGIT-0.9.1 v0.9.1
Jason A. Donenfeld [Thu, 15 Nov 2012 00:28:59 +0000 (01:28 +0100)]
CGIT-0.9.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>
12 years agoman: show mime type default value
Jason A. Donenfeld [Thu, 15 Nov 2012 00:26:06 +0000 (01:26 +0100)]
man: show mime type default value

12 years agossdiff: point line links at exact blob by prepending "id="
Julius Plenz [Tue, 30 Oct 2012 12:56:01 +0000 (13:56 +0100)]
ssdiff: point line links at exact blob by prepending "id="

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>
12 years agoFormat git diff headers correctly when adding or removing files.
Michael Halstead [Wed, 14 Nov 2012 20:41:01 +0000 (12:41 -0800)]
Format git diff headers correctly when adding or removing files.

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.

12 years agoMakefile: get snapshots from github
Ferry Huberts [Sat, 3 Nov 2012 23:49:45 +0000 (17:49 -0600)]
Makefile: get snapshots from github

Github will have more bandwidth than Lars' server.

12 years agoMakefile: remove tags file
Jamie Couture [Wed, 31 Oct 2012 23:43:12 +0000 (19:43 -0400)]
Makefile: remove tags file

Remove tags file from working directory.

Signed-off-by: Jamie Couture <jamie.couture@gmail.com>
12 years agoui-shared: use placeholder for empty commit subject
Christian Franke [Sun, 28 Oct 2012 17:36:08 +0000 (18:36 +0100)]
ui-shared: use placeholder for empty commit subject

Display a placeholder when creating links to commits with empty subjects.
This avoids the creation of links of the form <a></a>.

12 years agosyntax-highlighting.sh: Fix command injection.
Jason A. Donenfeld [Sun, 28 Oct 2012 02:03:41 +0000 (20:03 -0600)]
syntax-highlighting.sh: Fix command injection.

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.

12 years agoFix man page typo.
Jason A. Donenfeld [Thu, 18 Oct 2012 21:36:44 +0000 (23:36 +0200)]
Fix man page typo.

12 years agoMakefile: Support OpenBSD just like FreeBSD
Jason A. Donenfeld [Wed, 17 Oct 2012 19:55:48 +0000 (21:55 +0200)]
Makefile: Support OpenBSD just like FreeBSD

12 years agoMakefile: support FreeBSD libiconv paths
Jason A. Donenfeld [Wed, 17 Oct 2012 16:30:08 +0000 (18:30 +0200)]
Makefile: support FreeBSD libiconv paths

According to Dan Rue <drue@therub.org>, FreeBSD requires the lib paths
to get libiconv from /usr/local.

12 years agotests: check for proper html entity
Jason A. Donenfeld [Wed, 17 Oct 2012 15:17:48 +0000 (17:17 +0200)]
tests: check for proper html entity

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>
12 years agoui-log: Add "commit-sort" option for controlling commit ordering
Tobias Bieniek [Sat, 13 Oct 2012 14:10:30 +0000 (16:10 +0200)]
ui-log: Add "commit-sort" option for controlling commit ordering

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>
12 years agoui-repolist: Add "section-sort" flag to control section sorting.
Tobias Bieniek [Tue, 9 Oct 2012 18:53:29 +0000 (20:53 +0200)]
ui-repolist: Add "section-sort" flag to control section sorting.

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>
12 years agoscan-tree: Unify gitweb.* and cgit.* settings into one config option.
Jason A. Donenfeld [Tue, 9 Oct 2012 10:56:14 +0000 (06:56 -0400)]
scan-tree: Unify gitweb.* and cgit.* settings into one config option.

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

12 years agoui: Remember to print ampersand as proper html entities.
William Bell [Tue, 9 Oct 2012 18:45:58 +0000 (20:45 +0200)]
ui: Remember to print ampersand as proper html entities.

12 years agoui-repolist: Rename section-sort to repository-sort.
Jason A. Donenfeld [Tue, 16 Oct 2012 21:32:40 +0000 (23:32 +0200)]
ui-repolist: Rename section-sort to repository-sort.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
12 years agorepo_config: do not let globals override repo settings
Tobias Bieniek [Wed, 18 Apr 2012 10:32:13 +0000 (12:32 +0200)]
repo_config: do not let globals override repo settings

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>
12 years agoREADME: times, they are a-changin
Jason A. Donenfeld [Tue, 9 Oct 2012 11:21:30 +0000 (13:21 +0200)]
README: times, they are a-changin

12 years agosyntax-highlight: when the file has no extension, assume text
Ferry Huberts [Tue, 9 Oct 2012 11:10:48 +0000 (13:10 +0200)]
syntax-highlight: when the file has no extension, assume text

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>
12 years agoui-repolist: do not use agefile if it's date could not be parsed
Ferry Huberts [Tue, 9 Oct 2012 11:09:58 +0000 (13:09 +0200)]
ui-repolist: do not use agefile if it's date could not be parsed

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
12 years agoRevert "filters/syntax-highlighting.sh: work around highlight --force bug"
Ferry Huberts [Tue, 9 Oct 2012 11:08:30 +0000 (13:08 +0200)]
Revert "filters/syntax-highlighting.sh: work around highlight --force bug"

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>
12 years agoMakefile: add tag target to generate ctags
Jamie Couture [Mon, 8 Oct 2012 17:12:17 +0000 (13:12 -0400)]
Makefile: add tag target to generate ctags

Signed-off-by: Jamie Couture <jamie.couture@gmail.com>
12 years agoui-repolist: Bold the currently viewed page.
Jamie Couture [Mon, 8 Oct 2012 16:49:34 +0000 (12:49 -0400)]
ui-repolist: Bold the currently viewed page.

Signed-off-by: Jamie Couture <jamie.couture@gmail.com>
12 years agodo not write outside heap buffer
Jim Meyering [Mon, 23 Apr 2012 20:06:35 +0000 (22:06 +0200)]
do not write outside heap buffer

* 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.

12 years agoui-snapshot: pass -n to gzip, to suppress timestamp
Jason A. Donenfeld [Wed, 26 Sep 2012 00:56:38 +0000 (02:56 +0200)]
ui-snapshot: pass -n to gzip, to suppress timestamp

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.

12 years agoUpdate copyright headers to have latest dates.
Jason A. Donenfeld [Thu, 12 Jul 2012 18:00:40 +0000 (20:00 +0200)]
Update copyright headers to have latest dates.

12 years agoui-repolist: Case insensitive sorting and age sort
Jason A. Donenfeld [Thu, 12 Jul 2012 17:13:39 +0000 (19:13 +0200)]
ui-repolist: Case insensitive sorting and age sort

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.

12 years agoscan-tree: Support gitweb.category.
Jason A. Donenfeld [Wed, 11 Jul 2012 03:32:45 +0000 (05:32 +0200)]
scan-tree: Support gitweb.category.

Use gitweb.category from git config to determine repo's section, if
option is enabled.

12 years agoscan-tree: Support gitweb.description.
Jason A. Donenfeld [Wed, 11 Jul 2012 02:24:01 +0000 (04:24 +0200)]
scan-tree: Support gitweb.description.

Use gitweb.description instead of description file to determine
description, if option is enabled.

12 years agocss: only use div#cgit
Ferry Huberts [Mon, 19 Mar 2012 22:09:25 +0000 (23:09 +0100)]
css: only use div#cgit

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>
12 years agoMerge branch 'fh/mimetypes'
Lars Hjemli [Sun, 18 Mar 2012 21:01:28 +0000 (21:01 +0000)]
Merge branch 'fh/mimetypes'

12 years agoMerge branch 'jp/defbranch'
Lars Hjemli [Sun, 18 Mar 2012 21:00:18 +0000 (21:00 +0000)]
Merge branch 'jp/defbranch'

12 years agoMerge branch 'lh/module-links'
Lars Hjemli [Sun, 18 Mar 2012 20:59:36 +0000 (20:59 +0000)]
Merge branch 'lh/module-links'

12 years agoMerge branch 'stable'
Lars Hjemli [Sun, 18 Mar 2012 20:23:30 +0000 (20:23 +0000)]
Merge branch 'stable'

12 years agocss: force text color to black on decorations
Ferry Huberts [Sun, 18 Mar 2012 10:44:05 +0000 (11:44 +0100)]
css: force text color to black on decorations

improves readability when embedding into a page that
has the text color set to a different color

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
12 years agocss: vertically align the cgit logo image
Ferry Huberts [Sun, 18 Mar 2012 10:44:04 +0000 (11:44 +0100)]
css: vertically align the cgit logo image

When embedding cgit in other pages, the logo alignment needs to be
specified to avoid any css rules from the embedding page to make the
page look bad.

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
12 years agocss: prefix all styles with div#cgit
Ferry Huberts [Sun, 18 Mar 2012 10:44:03 +0000 (11:44 +0100)]
css: prefix all styles with div#cgit

to facilitate easier embedding

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
12 years agofilters/syntax-highlighting.sh: work around highlight --force bug
Ferry Huberts [Sun, 18 Mar 2012 11:48:01 +0000 (11:48 +0000)]
filters/syntax-highlighting.sh: work around highlight --force bug

12 years agofilters/highlight.sh: manually support highlight version 2 and 3
Ferry Huberts [Sun, 18 Mar 2012 11:38:26 +0000 (11:38 +0000)]
filters/highlight.sh: manually support highlight version 2 and 3

12 years agotests: properly quote arguments to printf
Ferry Huberts [Sun, 18 Mar 2012 10:43:50 +0000 (11:43 +0100)]
tests: properly quote arguments to printf

v2: incorporate remarks of Lukas

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
12 years agotests: handle paths with whitespace
Ferry Huberts [Sun, 18 Mar 2012 10:43:49 +0000 (11:43 +0100)]
tests: handle paths with whitespace

v2: incorporate remarks of Lukas

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
12 years agoMerge branch 'stable'
Lars Hjemli [Sun, 18 Mar 2012 10:19:59 +0000 (10:19 +0000)]
Merge branch 'stable'

12 years agoCGIT-0.9.0.3 v0.9.0.3
Lars Hjemli [Sun, 18 Mar 2012 10:16:27 +0000 (10:16 +0000)]
CGIT-0.9.0.3

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
12 years agoMerge branch 'stable'
Lars Hjemli [Sun, 18 Mar 2012 10:10:10 +0000 (10:10 +0000)]
Merge branch 'stable'

12 years agosegfault fix on some bogus requests
Eric Wong [Wed, 4 Jan 2012 09:01:51 +0000 (09:01 +0000)]
segfault fix on some bogus requests

ctx.qry.head can be NULL in some cases due to bad requests
by weird bots.  I managed to reproduce with:

   PATH_INFO=/repo.git/shop.php QUERY_STRING=id=

Signed-off-by: Eric Wong <normalperson@yhbt.net>
12 years agouse correct type for sizeof
Jamie Couture [Thu, 12 Jan 2012 03:38:49 +0000 (22:38 -0500)]
use correct type for sizeof

**L would have worked well too.  Depending on the distribution sizeof *L
may return 8 instead of 4. **L is preferable, but since we don't expect
this datatype to change very often, sizeof int is less subtle and easier
to understand.

Signed-off-by: Jamie Couture <jamie.couture@gmail.com>
12 years agoui-ssdiff.c: correct length check for LCS table
Eric Wong [Wed, 4 Jan 2012 08:59:15 +0000 (08:59 +0000)]
ui-ssdiff.c: correct length check for LCS table

Each individual string may be too long for its respective
dimension of the LCS table.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
12 years agoMerge branch 'stable'
Lars Hjemli [Tue, 3 Jan 2012 21:19:29 +0000 (21:19 +0000)]
Merge branch 'stable'

12 years agoFix segmentation fault in empty repository
John Keeping [Thu, 24 Nov 2011 11:54:47 +0000 (11:54 +0000)]
Fix segmentation fault in empty repository

When a repository is empty, the ATOM feed link is written in the header,
but this involves formatting ctx->qry.head which is NULL in this case.
With glibc, vsnprintf formats "%s" with a NULL input as "(null)" but on
Solaris this results in a segmentation fault.  Since we don't have a
meaningful head for the atom feed in an empty repository, it's simplest
not to write out the link element at all.

Signed-off-by: John Keeping <john@metanate.com>
12 years agoMerge branch 'stable'
Lars Hjemli [Tue, 3 Jan 2012 16:48:22 +0000 (16:48 +0000)]
Merge branch 'stable'

12 years agoMakefile: fetch git tarballs from http://hjemli.net/git/git/
Lars Hjemli [Tue, 3 Jan 2012 16:43:33 +0000 (16:43 +0000)]
Makefile: fetch git tarballs from http://hjemli.net/git/git/

The git tarballs are currently not available from kernel.org, so for now
the makefile will download autogenerated tarballs from cgit.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
12 years agofix css color value and vertical-align value
Norberto Lopes [Wed, 23 Nov 2011 01:59:26 +0000 (17:59 -0800)]
fix css color value and vertical-align value

12 years agoui-ssdiff.c: set correct diffmode in "control panel"
Tim Chen [Tue, 3 Jan 2012 16:09:59 +0000 (16:09 +0000)]
ui-ssdiff.c: set correct diffmode in "control panel"

When side-by-side-diffs=1 was set in cgitrc, specifying 'ss=0' in the
querystring would not set the 'unified' option as active in the dropdown
box used to select diffmode.

12 years agoMerge branch 'stable'
Lars Hjemli [Tue, 3 Jan 2012 16:06:58 +0000 (16:06 +0000)]
Merge branch 'stable'

12 years agoFix diff mode switching when side-by-side-diffs=1
Tim Chen [Tue, 3 Jan 2012 16:02:14 +0000 (16:02 +0000)]
Fix diff mode switching when side-by-side-diffs=1

When side-by-side-diffs=1 was set in cgitrc, specyfing 'ss=0' in the query-
string would not switch to unified diffs. This patch fixes the issue by
introducing a separate variable to track the occurrence of "ss" in the
querystring.

12 years agoui-log.c: do not show remote heads if enable-remote-branches=0
Georg Müller [Tue, 3 Jan 2012 15:30:50 +0000 (15:30 +0000)]
ui-log.c: do not show remote heads if enable-remote-branches=0

If remote branches are not enabled, the branches are still listed in
the log view. This patch removes them if enable-remote-branches=0.

12 years agoAdd sort parameter to pager of repo list
Tobias Grimm [Sun, 31 Jul 2011 00:44:05 +0000 (02:44 +0200)]
Add sort parameter to pager of repo list

When the repolist is paged, the page-links are missing the sort parameter,
causing the initial page to be custom sorted, but any clicked page will
then be with the default sort order again.

12 years agoui-ssdiff: move LCS table away from the stack
Jamie Couture [Sat, 17 Sep 2011 22:25:01 +0000 (18:25 -0400)]
ui-ssdiff: move LCS table away from the stack

Printing deferred line changes for files containing long lines would
cause a segfault.

- limit LCS table size: 128x128.
- move LCS table to global context: avoid allocating/freeing memory
  for every deferred line change.

Signed-off-by: Jamie Couture <jamie.couture@gmail.com>
12 years agoshared.c: Only setenv() if value is non-null
Lukas Fleischer [Wed, 14 Sep 2011 09:52:43 +0000 (11:52 +0200)]
shared.c: Only setenv() if value is non-null

Some setenv() implementations (e.g. the one in OpenBSD's stdlib)
segfault if we pass a NULL value. Only set environment variables if the
corresponding settings are defined to avoid this.

Note that this is a minor behaviour change as environment variables were
supposed to be set to an empty string if a setting was undefined. Given
that this feature isn't part of any official release yet, there's no
need to worry about backwards compatibility, really. Change the
documentation accordingly.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
12 years agoshared.c: Remove unused "linux/limits.h" include
Lukas Fleischer [Fri, 22 Jul 2011 15:15:49 +0000 (17:15 +0200)]
shared.c: Remove unused "linux/limits.h" include

This isn't used anywhere and prevents the code from being compiled on
other platforms, such as *BSD.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
13 years agoMerge branch 'stable'
Lars Hjemli [Fri, 22 Jul 2011 12:22:17 +0000 (12:22 +0000)]
Merge branch 'stable'

13 years agoFix potential XSS vulnerability in rename hint
Lukas Fleischer [Fri, 22 Jul 2011 11:47:19 +0000 (13:47 +0200)]
Fix potential XSS vulnerability in rename hint

The file name displayed in the rename hint should be escaped to avoid
XSS. Note that this vulnerability is only applicable when an attacker
has gained push access to the repository.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
13 years agoRemove dead initialization in cgit_parse_commit()
Lukas Fleischer [Thu, 21 Jul 2011 21:04:53 +0000 (23:04 +0200)]
Remove dead initialization in cgit_parse_commit()

The value stored to "t" during its initialization gets overwritten in
any case, so just leave it uninitialized. Spotted by clang-analyzer.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
13 years agoMerge branch 'stable'
Lars Hjemli [Thu, 21 Jul 2011 14:27:03 +0000 (14:27 +0000)]
Merge branch 'stable'