aboutsummaryrefslogtreecommitdiff
path: root/titan.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2023-08-04 09:57:27 +0000
committerOmar Polo <op@omarpolo.com>2023-08-04 09:57:27 +0000
commitd671434bc76ec81a34e64ae0c164a831cbee4b0d (patch)
treeecac181dcf758c7524646a056bb47420b713dcd2 /titan.c
parent59051566657ab3888ef841cf46cf0588bf57e746 (diff)
titan: better logging for unexpected EOFs
upon an unexpected EOF, tls_error() returns NULL, so log the real reason iomux returned -1.
Diffstat (limited to 'titan.c')
-rw-r--r--titan.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/titan.c b/titan.c
index 9b8e463..e57ff67 100644
--- a/titan.c
+++ b/titan.c
@@ -347,8 +347,12 @@ main(int argc, char **argv)
buflen = fread(buf, 1, sizeof(buf), in);
w = iomux(ctx, sock, buf, buflen, resbuf, sizeof(resbuf));
- if (w == -1)
- errx(1, "I/O error: %s", tls_error(ctx));
+ if (w == -1) {
+ errstr = tls_error(ctx);
+ if (errstr == NULL)
+ errstr = "unexpected EOF";
+ errx(1, "I/O error: %s", errstr);
+ }
if (w != 0) {
if ((m = memmem(resbuf, w, "\r\n", 2)) == NULL)
errx(1, "invalid reply");