diff options
author | Lars Hjemli | 2009-08-17 09:19:05 +0200 |
---|---|---|
committer | Lars Hjemli | 2009-08-17 09:24:36 +0200 |
commit | 8a631b1173b1abecc5a737b0e21751ddbabf9df2 (patch) | |
tree | 93320a0e21c1f13e936ccac66d250b28fa87acc1 | |
parent | CGIT 0.8.2.1 (diff) | |
download | cgit-8a631b1173b1abecc5a737b0e21751ddbabf9df2.tar.gz cgit-8a631b1173b1abecc5a737b0e21751ddbabf9df2.zip |
ui-tag.c: do not segfault when id is missing from query-string
The purpose of the tag page is to print info about a specific tag, but if no tag was specified on the query-string cgit used to segfault. With this patch, cgit will fallback to the value of the 'h' parameter instead (which is never NULL due to prepare_repo_cmd() in cgit.c). It will now also verify that the specified tagname is in fact a valid ref in the 'refs/tags/' namespace, i.e. specifying 'id=master' will trigger a 'Bad tag reference' error. Noticed-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-tag.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/ui-tag.c b/ui-tag.c index 0e056e0..8c263ab 100644 --- a/ui-tag.c +++ b/ui-tag.c | |||
@@ -37,7 +37,10 @@ void cgit_print_tag(char *revname) | |||
37 | struct tag *tag; | 37 | struct tag *tag; |
38 | struct taginfo *info; | 38 | struct taginfo *info; |
39 | 39 | ||
40 | if (get_sha1(revname, sha1)) { | 40 | if (!revname) |
41 | revname = ctx.qry.head; | ||
42 | |||
43 | if (get_sha1(fmt("refs/tags/%s", revname), sha1)) { | ||
41 | cgit_print_error(fmt("Bad tag reference: %s", revname)); | 44 | cgit_print_error(fmt("Bad tag reference: %s", revname)); |
42 | return; | 45 | return; |
43 | } | 46 | } |