about summary refs log tree commit diff
path: root/ui-patch.c
diff options
context:
space:
mode:
authorChristian Hesse <mail@eworm.de>2015-08-14 00:02:50 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2015-08-14 12:35:25 +0200
commitaa12084f9835783abbd1f1e4609f8de05e73cec4 (patch)
treea546f596e980b2e7c484b935b0ff8cbdaadf10ce /ui-patch.c
parentMakefile: make "git/config.mak.uname" inclusion optional (diff)
downloadcgit-pink-aa12084f9835783abbd1f1e4609f8de05e73cec4.tar.gz
cgit-pink-aa12084f9835783abbd1f1e4609f8de05e73cec4.zip
ui-patch: make sure to send http headers
Requesting a text/plain patch with bad commit id made cgit send text
without proper http headers. This results in "500 Internal Server Error"
with "Premature end of script headers" in server logs.
So print http headers before error message and return.

Signed-off-by: Christian Hesse <mail@eworm.de>
Reviewed-by: John Keeping <john@keeping.me.uk>
Diffstat (limited to '')
-rw-r--r--ui-patch.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/ui-patch.c b/ui-patch.c
index 6ec89b4..57ca2f8 100644
--- a/ui-patch.c
+++ b/ui-patch.c
@@ -25,21 +25,25 @@ void cgit_print_patch(const char *new_rev, const char *old_rev,
 		new_rev = ctx.qry.head;
 
 	if (get_sha1(new_rev, new_rev_sha1)) {
+		cgit_print_http_headers();
 		cgit_print_error("Bad object id: %s", new_rev);
 		return;
 	}
 	commit = lookup_commit_reference(new_rev_sha1);
 	if (!commit) {
+		cgit_print_http_headers();
 		cgit_print_error("Bad commit reference: %s", new_rev);
 		return;
 	}
 
 	if (old_rev) {
 		if (get_sha1(old_rev, old_rev_sha1)) {
+			cgit_print_http_headers();
 			cgit_print_error("Bad object id: %s", old_rev);
 			return;
 		}
 		if (!lookup_commit_reference(old_rev_sha1)) {
+			cgit_print_http_headers();
 			cgit_print_error("Bad commit reference: %s", old_rev);
 			return;
 		}
7409e336620c0&follow=1'>Hack clang into checking uiFmt format stringsJune McEnroe 2018-08-07Handle PART and QUIT without messagesJune McEnroe 2018-08-07Make safe filling the who bufferJune McEnroe 2018-08-07Add reverse and reset IRC formatting codesJune McEnroe 2018-08-06Rewrite line editing again, add formattingJune McEnroe 2018-08-06Fix allocation size in vaswprintfJune McEnroe 2018-08-06Implement word wrappingJune McEnroe 2018-08-06Use wchar_t strings for all of UIJune McEnroe 2018-08-06Rename line editing functionsJune McEnroe 2018-08-05Initialize all possible color pairsJune McEnroe 2018-08-05Refactor color initializationJune McEnroe 2018-08-05Add ^L redrawJune McEnroe 2018-08-05Use 16 colors if availableJune McEnroe 2018-08-05Limit parsed colors to number of mIRC colorsJune McEnroe 2018-08-04Show source link on exitJune McEnroe 2018-08-04Implement line editing, scrollingJune McEnroe 2018-08-04Handle /topicJune McEnroe