Commit 6918c6095815222b3887c6d86a27772826a9ac7a

Tracey Emery 2020-04-14T17:40:42

remove all asprintf from gw_output_site_link and fix error handling

diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index 929d046..f4118d2 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -4446,9 +4446,9 @@ gw_output_site_link(struct gw_trans *gw_trans)
 		kerr = khtml_puts(gw_trans->gw_html_req, " / ");
 		if (kerr != KCGI_OK)
 			goto done;
-		if (asprintf(&href_summary, "?path=%s&action=summary",
-		    gw_trans->repo_name) == -1)
-			goto done;
+
+		href_summary = khttp_urlpart(NULL, NULL, "gotweb", "path",
+		    gw_trans->repo_name, "action", "summary", NULL),
 		kerr = khtml_attr(gw_trans->gw_html_req, KELEM_A, KATTR_HREF,
 		    href_summary, KATTR__MAX);
 		if (kerr != KCGI_OK)
@@ -4470,6 +4470,8 @@ gw_output_site_link(struct gw_trans *gw_trans)
 		goto done;
 done:
 	free(href_summary);
+	if (error == NULL && kerr != KCGI_OK)
+		error = gw_kcgi_error(kerr);
 	return error;
 }