about summary refs log tree commit diff
diff options
context:
space:
mode:
#!/bin/sh## An example hook to update the "agefile" for CGit's idle time calculation.## This hook assumes that you are using the default agefile location of# "info/web/last-modified". If you change the value in your cgitrc then you# must also change it here.## To install the hook, copy (or link) it to the file "hooks/post-receive" in# each of your repositories.# agefile="$(git rev-parse --git-dir)"/info/web/last-modified mkdir -p "$(dirname "$agefile")"&& git for-each-ref \ --sort=-authordate --count=1 \ --format='%(authordate:iso8601)' \ >"$agefile"
authorJune McEnroe <june@causal.agency>2020-07-24 14:19:41 -0400
committerJune McEnroe <june@causal.agency>2020-07-24 14:19:41 -0400
commit434a537d660d41b030e409a3c3d9d0ffafe0c8f2 (patch)
d class='none' style='width: 0.0%;'/>
1 files changed, 6 insertions, 4 deletions
diff --git a/scoop.c b/scoop.c
index 4721c73..c71e99d 100644
--- a/scoop.c
+++ b/scoop.c
@@ -536,10 +536,10 @@ int main(int argc, char *argv[]) {
 	}
 
 	sqlite3_stmt *stmt;
-	char query[QueryCap];
+	char *query = NULL;
 	if (sort) {
-		snprintf(
-			query, sizeof(query),
+		asprintf(
+			&query,
 			SQL(
 				WITH results AS (%s %s %s)
 				SELECT * FROM results
@@ -548,9 +548,11 @@ int main(int argc, char *argv[]) {
 			select, from, where, (group ? "network, context," : "")
 		);
 	} else {
-		snprintf(query, sizeof(query), "%s %s %s;", select, from, where);
+		asprintf(&query, "%s %s %s;", select, from, where);
 	}
+	if (!query) err(EX_OSERR, "asprintf");
 	stmt = dbPrepare(query);
+	free(query);
 
 	for (int i = 0; i < n; ++i) {
 		if (binds[i].text) {