Introduction
Introduction Statistics Contact Development Disclaimer Help
tls: Fix a crash on invalid cert in non-interactive mode - sacc - sacc - sacc(o…
git clone git://git.codemadness.org/sacc
Log
Files
Refs
LICENSE
---
commit 5b9bcbd0dcf3cf2c4edb995621de245ce6b80a9d
parent 4003310026b26f9c81b44fb07686e7301064c4bf
Author: Hiltjo Posthuma <[email protected]>
Date: Wed, 18 Jan 2023 23:52:32 +0100
tls: Fix a crash on invalid cert in non-interactive mode
This is because uiprompt() cannot be used in non-interactive.
To reproduce:
Put a different certificate in ~/.share/sacc/cert/bitreich.org
Then run:
sacc gophers://bitreich.org > /tmp/plop
Diffstat:
M common.h | 2 ++
M io_tls.c | 5 +++++
M sacc.c | 2 +-
3 files changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/common.h b/common.h
@@ -23,6 +23,8 @@ struct dir {
size_t curline;
};
+extern int interactive;
+
extern void (*diag)(char *, ...);
extern void die(const char *, ...);
diff --git a/io_tls.c b/io_tls.c
@@ -210,6 +210,11 @@ connect_tls(struct cnx *c, struct addrinfo *ai, const char…
diag("Can't establish TLS with \"%s\": %s",
host, tls_error(t));
+ if (!interactive) {
+ r = CONN_ABORT;
+ goto end;
+ }
+
if (pem.cert) {
s = uiprompt("Save certificate locally and retry? [yN]…
switch (*s) {
diff --git a/sacc.c b/sacc.c
@@ -49,6 +49,7 @@ enum {
void (*diag)(char *, ...);
+int interactive;
const char ident[] = "@(#) sacc(omys): " VERSION;
static char intbuf[256]; /* 256B ought to be enough for any URI */
@@ -56,7 +57,6 @@ static char *mainurl;
static Item *mainentry;
static int devnullfd;
static int parent = 1;
-static int interactive;
static void
stddiag(char *fmt, ...)
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.