diff options
author | jsing <> | 2015-08-27 15:26:50 +0000 |
---|---|---|
committer | jsing <> | 2015-08-27 15:26:50 +0000 |
commit | 4cf0ea2d0621bc7128cf6a7cb3ed6a178f835617 (patch) | |
tree | d2c2a8c6fc1b8da3c4117997a97ab03f0ac74f21 /src/lib/libtls/tls_internal.h | |
parent | 9385a1fd21f3850678c58b5cc8702c3a54b91ead (diff) | |
download | openbsd-4cf0ea2d0621bc7128cf6a7cb3ed6a178f835617.tar.gz openbsd-4cf0ea2d0621bc7128cf6a7cb3ed6a178f835617.tar.bz2 openbsd-4cf0ea2d0621bc7128cf6a7cb3ed6a178f835617.zip |
Improve libtls error messages.
The tls_set_error() function previously stored the errno but did nothing
with it. Change tls_set_error() to append the strerror(3) of the stored
errno so that we include useful information regarding failures.
Provide a tls_set_errorx() function that does not store the errno or
include strerror(3) in the error message. Call this function instead of
tls_set_error() for errors where the errno value has no useful meaning.
With feedback from and ok doug@
Diffstat (limited to 'src/lib/libtls/tls_internal.h')
-rw-r--r-- | src/lib/libtls/tls_internal.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/lib/libtls/tls_internal.h b/src/lib/libtls/tls_internal.h index cf4a8e28ad..4503c20ab7 100644 --- a/src/lib/libtls/tls_internal.h +++ b/src/lib/libtls/tls_internal.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls_internal.h,v 1.13 2015/08/27 14:34:46 jsing Exp $ */ | 1 | /* $OpenBSD: tls_internal.h,v 1.14 2015/08/27 15:26:50 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Jeremie Courreges-Anglas <jca@openbsd.org> | 3 | * Copyright (c) 2014 Jeremie Courreges-Anglas <jca@openbsd.org> |
4 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 4 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
@@ -59,8 +59,8 @@ struct tls { | |||
59 | uint32_t flags; | 59 | uint32_t flags; |
60 | uint32_t state; | 60 | uint32_t state; |
61 | 61 | ||
62 | int err; | ||
63 | char *errmsg; | 62 | char *errmsg; |
63 | int errnum; | ||
64 | 64 | ||
65 | int socket; | 65 | int socket; |
66 | 66 | ||
@@ -76,7 +76,10 @@ int tls_configure_keypair(struct tls *ctx); | |||
76 | int tls_configure_server(struct tls *ctx); | 76 | int tls_configure_server(struct tls *ctx); |
77 | int tls_configure_ssl(struct tls *ctx); | 77 | int tls_configure_ssl(struct tls *ctx); |
78 | int tls_host_port(const char *hostport, char **host, char **port); | 78 | int tls_host_port(const char *hostport, char **host, char **port); |
79 | int tls_set_error(struct tls *ctx, char *fmt, ...) | 79 | int tls_set_error(struct tls *ctx, const char *fmt, ...) |
80 | __attribute__((__format__ (printf, 2, 3))) | ||
81 | __attribute__((__nonnull__ (2))); | ||
82 | int tls_set_errorx(struct tls *ctx, const char *fmt, ...) | ||
80 | __attribute__((__format__ (printf, 2, 3))) | 83 | __attribute__((__format__ (printf, 2, 3))) |
81 | __attribute__((__nonnull__ (2))); | 84 | __attribute__((__nonnull__ (2))); |
82 | int tls_ssl_error(struct tls *ctx, SSL *ssl_conn, int ssl_ret, | 85 | int tls_ssl_error(struct tls *ctx, SSL *ssl_conn, int ssl_ret, |