diff options
author | C. McEnroe | 2021-10-16 17:03:31 -0400 |
---|---|---|
committer | C. McEnroe | 2021-10-16 17:03:31 -0400 |
commit | b6cf41ab77a4324b4f4cf0bc9e3d82a5fef9ebd4 (patch) | |
tree | 45fb76bbe6f5037d5827130c89e63e6d9cc22c16 /irc.c | |
parent | 54c632e8c35c3283a890c589f1b7937887c13877 (diff) |
Import refactored xdg.c from pounce
Diffstat (limited to 'irc.c')
-rw-r--r-- | irc.c | 22 |
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)); |