summary refs log tree commit diff
path: root/irc.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-10-16 17:03:31 -0400
committerJune McEnroe <june@causal.agency>2021-10-16 17:03:31 -0400
commitb6cf41ab77a4324b4f4cf0bc9e3d82a5fef9ebd4 (patch)
tree45fb76bbe6f5037d5827130c89e63e6d9cc22c16 /irc.c
parentchroot: Factor out and add OpenBSD build (diff)
downloadcatgirl-b6cf41ab77a4324b4f4cf0bc9e3d82a5fef9ebd4.tar.gz
catgirl-b6cf41ab77a4324b4f4cf0bc9e3d82a5fef9ebd4.zip
Import refactored xdg.c from pounce
Diffstat (limited to 'irc.c')
-rw-r--r--irc.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/irc.c b/irc.c
index 8d5ae81..20e9f91 100644
--- a/irc.c
+++ b/irc.c
@@ -29,6 +29,7 @@
 #include <err.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <limits.h>
 #include <netdb.h>
 #include <netinet/in.h>
 #include <stdarg.h>
@@ -49,19 +50,20 @@ static struct tls_config *config;
 void ircConfig(
 	bool insecure, const char *trust, const char *cert, const char *priv
 ) {
+	int error = 0;
+	char buf[PATH_MAX];
+
 	config = tls_config_new();
 	if (!config) errx(EX_SOFTWARE, "tls_config_new");
 
-	int error = 0;
 	if (insecure) {
 		tls_config_insecure_noverifycert(config);
 		tls_config_insecure_noverifyname(config);
 	}
 	if (trust) {
 		tls_config_insecure_noverifyname(config);
-		const char *dirs = NULL;
-		for (const char *path; NULL != (path = configPath(&dirs, trust));) {
-			error = tls_config_set_ca_file(config, path);
+		for (int i = 0; configPath(buf, sizeof(buf), trust, i); ++i) {
+			error = tls_config_set_ca_file(config, buf);
 			if (!error) break;
 		}
 		if (error) errx(EX_NOINPUT, "%s: %s", trust, tls_config_error(config));
@@ -79,21 +81,19 @@ void ircConfig(
 #endif
 
 	if (cert) {
-		const char *dirs = NULL;
-		for (const char *path; NULL != (path = configPath(&dirs, cert));) {
+		for (int i = 0; configPath(buf, sizeof(buf), cert, i); ++i) {
 			if (priv) {
-				error = tls_config_set_cert_file(config, path);
+				error = tls_config_set_cert_file(config, buf);
 			} else {
-				error = tls_config_set_keypair_file(config, path, path);
+				error = tls_config_set_keypair_file(config, buf, buf);
 			}
 			if (!error) break;
 		}
 		if (error) errx(EX_NOINPUT, "%s: %s", cert, tls_config_error(config));
 	}
 	if (priv) {
-		const char *dirs = NULL;
-		for (const char *path; NULL != (path = configPath(&dirs, priv));) {
-			error = tls_config_set_key_file(config, path);
+		for (int i = 0; configPath(buf, sizeof(buf), priv, i); ++i) {
+			error = tls_config_set_key_file(config, buf);
 			if (!error) break;
 		}
 		if (error) errx(EX_NOINPUT, "%s: %s", priv, tls_config_error(config));