tls: Fix certificate path length calculation - sacc - sacc(omys), simple consol… | |
git clone git://bitreich.org/sacc/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65… | |
Log | |
Files | |
Refs | |
Tags | |
LICENSE | |
--- | |
commit 8b2a2eaf79da098717fe9a7d87fca9fa1f6c6579 | |
parent 9dec9b200c1bddd6d12f4aa6b43e2c329f513235 | |
Author: Quentin Rameau <[email protected]> | |
Date: Sat, 15 Oct 2022 23:10:38 +0200 | |
tls: Fix certificate path length calculation | |
Thanks to Hiltjo for spotting this! | |
Diffstat: | |
M io_tls.c | 8 ++++---- | |
1 file changed, 4 insertions(+), 4 deletions(-) | |
--- | |
diff --git a/io_tls.c b/io_tls.c | |
@@ -23,7 +23,7 @@ struct pem { | |
char path[PATH_MAX]; | |
char *dir; | |
char *cert; | |
- size_t certln; | |
+ size_t certsz; | |
}; | |
int tls; | |
@@ -78,7 +78,7 @@ setup_tls(void) | |
pem.path, strerror(errno)); | |
} else { | |
pem.cert = pem.path + n; | |
- pem.certln = pem.cert - pem.path; | |
+ pem.certsz = sizeof(pem.path) - n; | |
} | |
return 0; | |
@@ -133,8 +133,8 @@ conftls(struct tls *t, const char *host) | |
if (pem.cert == NULL) | |
return NULL; | |
- n = snprintf(pem.cert, pem.certln, host); | |
- if (n < 0 || (unsigned)n >= pem.certln) { | |
+ n = snprintf(pem.cert, pem.certsz, "%s", host); | |
+ if (n < 0 || (unsigned)n >= pem.certsz) { | |
diag("PEM path too long: %s/%s", pem.cert, host); | |
return NULL; | |
} |