summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-07-31 23:51:23 -0400
committerJune McEnroe <june@causal.agency>2020-07-31 23:51:23 -0400
commit8a91c64edf551c3c05483ec3f5c87e8dc27a3cc5 (patch)
treecee269932d1d455b2086db9016bae51a196e3867
parentUse RAND_bytes instead of arc4random_buf (diff)
downloadpounce-8a91c64edf551c3c05483ec3f5c87e8dc27a3cc5.tar.gz
pounce-8a91c64edf551c3c05483ec3f5c87e8dc27a3cc5.zip
Use snprintf instead of strlcpy
Diffstat (limited to '')
-rw-r--r--bounce.c6
-rw-r--r--client.c2
-rw-r--r--compat.h3
-rw-r--r--local.c6
4 files changed, 9 insertions, 8 deletions
diff --git a/bounce.c b/bounce.c
index c9b27b0..bee8aca 100644
--- a/bounce.c
+++ b/bounce.c
@@ -352,16 +352,16 @@ int main(int argc, char *argv[]) {
 		switch (opt) {
 			break; case '!': insecure = true;
 			break; case 'A': clientCA = true; caPath = optarg;
-			break; case 'C': strlcpy(certPath, optarg, sizeof(certPath));
+			break; case 'C': snprintf(certPath, sizeof(certPath), "%s", optarg);
 			break; case 'H': bindHost = optarg;
-			break; case 'K': strlcpy(privPath, optarg, sizeof(privPath));
+			break; case 'K': snprintf(privPath, sizeof(privPath), "%s", optarg);
 			break; case 'N': stateNoNames = true;
 			break; case 'P': bindPort = optarg;
 			break; case 'Q': serverQueueInterval = parseInterval(optarg);
 			break; case 'R': blindReq |= capParse(optarg, NULL);
 			break; case 'S': serverBindHost = optarg;
 			break; case 'T': clientSTS = false;
-			break; case 'U': strlcpy(bindPath, optarg, sizeof(bindPath));
+			break; case 'U': snprintf(bindPath, sizeof(bindPath), "%s", optarg);
 			break; case 'W': clientPass = optarg;
 			break; case 'a': blindReq |= CapSASL; plain = optarg;
 			break; case 'c': clientCert = optarg;
diff --git a/client.c b/client.c
index 7f9a06a..4f315c8 100644
--- a/client.c
+++ b/client.c
@@ -428,7 +428,7 @@ static char *snip(char *dst, size_t cap, const char *src, const regex_t *regex)
 		);
 		if (len >= cap) return NULL;
 	}
-	len += strlcpy(&dst[len], src, cap - len);
+	len += snprintf(&dst[len], cap - len, "%s", src);
 	return (len < cap ? dst : NULL);
 }
 
diff --git a/compat.h b/compat.h
index 63109a0..4559434 100644
--- a/compat.h
+++ b/compat.h
@@ -30,8 +30,7 @@
 
 // libcrypto defines these functions if libc doesn't.
 void explicit_bzero(void *b, size_t len);
-#ifndef strlcpy
-size_t strlcpy(char *restrict dst, const char *restrict src, size_t dstsize);
+#ifndef strlcat
 size_t strlcat(char *restrict dst, const char *restrict src, size_t dstsize);
 #endif
 
diff --git a/local.c b/local.c
index 1e19ae5..b3670ee 100644
--- a/local.c
+++ b/local.c
@@ -161,8 +161,10 @@ size_t localUnix(int fds[], size_t cap, const char *path) {
 	if (sock < 0) err(EX_OSERR, "socket");
 
 	struct sockaddr_un addr = { .sun_family = AF_UNIX };
-	size_t len = strlcpy(addr.sun_path, path, sizeof(addr.sun_path));
-	if (len >= sizeof(addr.sun_path)) {
+	int len = snprintf(
+		addr.sun_path, sizeof(addr.sun_path), "%s", path
+	);
+	if ((size_t)len >= sizeof(addr.sun_path)) {
 		errx(EX_CONFIG, "path too long: %s", path);
 	}
 
"commit" UIs to respect the follow flag on URLs, causing the single-file version of these UIs to detect renames. This feature is needed only for commits that rename the path we're interested in. For commits before the file has been renamed (i.e. that appear later in the log list) we change the file path in the links from the log to point to the old name; this means that links to commits always limit by the path known to that commit. If we didn't do this we would need to walk down the log diff'ing every commit whenever we want to show a commit. The drawback is that the "Log" link in the top bar of such a page links to the log limited by the old name, so it will only show pre-rename commits. I consider this a reasonable trade-off since the "Back" button still works and the log matches the path displayed in the top bar. Since following renames requires running diff on every commit we consider, I've added a knob to the configuration file to globally enable/disable this feature. Note that we may consider a large number of commits the revision walking machinery no longer performs any path limitation so we have to examine every commit until we find a page full of commits that affect the target path or something related to it. Suggested-by: René Neumann <necoro@necoro.eu> Signed-off-by: John Keeping <john@keeping.me.uk> 2015-08-12shared: make cgit_diff_tree_cb publicJohn Keeping This will allow us to use this nice wrapper function elsewhere, avoiding dealing with the diff queue when we only need to inspect a filepair. Signed-off-by: John Keeping <john@keeping.me.uk> 2015-08-12t0110: Chain together using &&Jason A. Donenfeld 2015-08-12about: always ensure page has a trailing slashJason A. Donenfeld Otherwise we can't easily embed links to other /about/ pages. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2015-08-12filters: apply HTML escapingLazaros Koromilas http://www.w3.org/International/questions/qa-escapes#use 2015-08-12git: update to v2.5.0Christian Hesse Update to git version v2.5.0. * Upstream commit 5455ee0573a22bb793a7083d593ae1ace909cd4c (Merge branch 'bc/object-id') changed API: for_each_ref() callback functions were taught to name the objects not with "unsigned char sha1[20]" but with "struct object_id". * Upstream commit dcf692625ac569fefbe52269061230f4fde10e47 (path.c: make get_pathname() call sites return const char *) Signed-off-by: Christian Hesse <mail@eworm.de> 2015-08-12Fix processing of repo.hide and repo.ignoreDaniel Reichelt