If ERR_reason_error_string() returns NULL, fall back on strerror(errno).
That way we get reasonable error messages for missing files, etc.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: ISC
|
||||
*
|
||||
* Copyright (c) 2019-2021 Todd C. Miller <Todd.Miller@sudo.ws>
|
||||
* Copyright (c) 2019-2022 Todd C. Miller <Todd.Miller@sudo.ws>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -153,7 +153,8 @@ tls_connect_cb(int sock, int what, void *v)
|
||||
goto bad;
|
||||
default:
|
||||
errstr = ERR_reason_error_string(ERR_get_error());
|
||||
sudo_warnx(U_("TLS connection failed: %s"), errstr);
|
||||
sudo_warnx(U_("TLS connection failed: %s"),
|
||||
errstr ? errstr : strerror(errno));
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
@@ -187,21 +188,22 @@ tls_ctx_client_setup(SSL_CTX *ssl_ctx, int sock,
|
||||
|
||||
if ((closure->ssl = SSL_new(ssl_ctx)) == NULL) {
|
||||
errstr = ERR_reason_error_string(ERR_get_error());
|
||||
sudo_warnx(U_("unable to allocate ssl object: %s"), errstr);
|
||||
sudo_warnx(U_("unable to allocate ssl object: %s"),
|
||||
errstr ? errstr : strerror(errno));
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (SSL_set_ex_data(closure->ssl, 1, closure->peer_name) <= 0) {
|
||||
errstr = ERR_reason_error_string(ERR_get_error());
|
||||
sudo_warnx(U_("Unable to attach user data to the ssl object: %s"),
|
||||
errstr);
|
||||
errstr ? errstr : strerror(errno));
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (SSL_set_fd(closure->ssl, sock) <= 0) {
|
||||
errstr = ERR_reason_error_string(ERR_get_error());
|
||||
sudo_warnx(U_("Unable to attach socket to the ssl object: %s"),
|
||||
errstr);
|
||||
errstr ? errstr : strerror(errno));
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user