Commit 9f33591a82266a25a3e1f1c1afe1550345a1d7a0

Tracey Emery 2020-02-14T22:26:09

check required querystring commit exists for gw_tags

diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index d2f3218..ca4789a 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -1440,7 +1440,12 @@ gw_tag(struct gw_trans *gw_trans)
 	if (error)
 		goto done;
 
-	khttp_puts(gw_trans->gw_req, header->commit_id);
+	if (gw_trans->commit_id == NULL) {
+		error = got_error_msg(GOT_ERR_QUERYSTRING,
+		    "commit required in querystring");
+		goto done;
+	}
+
 	error = gw_get_header(gw_trans, header, 1);
 	if (error)
 		goto done;
diff --git a/include/got_error.h b/include/got_error.h
index 888f9dd..ae6efb2 100644
--- a/include/got_error.h
+++ b/include/got_error.h
@@ -130,6 +130,7 @@
 #define GOT_ERR_GITCONFIG_SYNTAX 114
 #define GOT_ERR_REBASE_OUT_OF_DATE 115
 #define GOT_ERR_CACHE_DUP_ENTRY	116
+#define GOT_ERR_QUERYSTRING	117
 
 static const struct got_error {
 	int code;
@@ -267,6 +268,7 @@ static const struct got_error {
 	{ GOT_ERR_REBASE_OUT_OF_DATE, "work tree must be updated before it "
 	    "can be used to rebase a branch" },
 	{ GOT_ERR_CACHE_DUP_ENTRY, "duplicate cache entry" },
+	{ GOT_ERR_QUERYSTRING, "bad querystring" },
 };
 
 /*