summaryrefslogtreecommitdiff
path: root/testcode/petal.c
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2026-05-22 14:08:07 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2026-05-22 14:08:07 +0000
commit4dd0a17edce60370304a45f2c40251e09e193bd6 (patch)
treef0cb0f27a9e83b56f8383265413d035ab01926c6 /testcode/petal.c
parentec5b94f552d7cb2a9d456c67e9941bcf5e3698bf (diff)
Diffstat (limited to 'testcode/petal.c')
-rw-r--r--testcode/petal.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/testcode/petal.c b/testcode/petal.c
index 627c77d57529..ec99a092d9bd 100644
--- a/testcode/petal.c
+++ b/testcode/petal.c
@@ -160,11 +160,26 @@ read_ssl_line(SSL* ssl, char* buf, size_t len)
return 0;
}
if((r = SSL_read(ssl, buf+n, 1)) <= 0) {
- if(SSL_get_error(ssl, r) == SSL_ERROR_ZERO_RETURN) {
+ int e = SSL_get_error(ssl, r);
+ if(e == SSL_ERROR_ZERO_RETURN) {
/* EOF */
break;
+ } else if(e == SSL_ERROR_WANT_READ) {
+ continue;
+ } else if(e == SSL_ERROR_WANT_WRITE) {
+ continue;
+ } else if(e == SSL_ERROR_SYSCALL) {
+ if(verb) printf("could not SSL_read %s\n",
+ strerror(errno));
+ } else if(e == SSL_ERROR_SSL) {
+ int er = ERR_peek_error();
+ if(er)
+ printf("could not SSL_read: %s\n",
+ ERR_reason_error_string(er));
+ } else {
+ if(verb) printf("could not SSL_read "
+ "(SSL_get_error %d)\n", e);
}
- if(verb) printf("could not SSL_read\n");
return 0;
}
if(endnl && buf[n] == '\n') {
@@ -222,7 +237,8 @@ read_http_headers(SSL* ssl, char* file, size_t flen, char* host, size_t hlen,
if(verb>=2) printf("read: %s\n", buf);
if(buf[0] == 0) {
int e = ERR_peek_error();
- printf("error string: %s\n", ERR_reason_error_string(e));
+ if(e)
+ printf("error string: %s\n", ERR_reason_error_string(e));
return 1;
}
if(!process_one_header(buf, file, flen, host, hlen, vs))
@@ -246,7 +262,8 @@ setup_ctx(char* key, char* cert)
#endif
if(!SSL_CTX_use_certificate_chain_file(ctx, cert)) {
int e = ERR_peek_error();
- printf("error string: %s\n", ERR_reason_error_string(e));
+ if(e)
+ printf("error string: %s\n", ERR_reason_error_string(e));
print_exit("cannot read cert");
}
if(!SSL_CTX_use_PrivateKey_file(ctx, key, SSL_FILETYPE_PEM))
@@ -673,12 +690,20 @@ int main(int argc, char* argv[])
#else
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS
| OPENSSL_INIT_ADD_ALL_DIGESTS
- | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
+ | OPENSSL_INIT_LOAD_CRYPTO_STRINGS
+# if defined(OPENSSL_INIT_NO_LOAD_CONFIG) && defined(UB_ON_WINDOWS)
+ | OPENSSL_INIT_NO_LOAD_CONFIG
+# endif
+ , NULL);
#endif
#if OPENSSL_VERSION_NUMBER < 0x10100000 || !defined(HAVE_OPENSSL_INIT_SSL)
(void)SSL_library_init();
#else
- (void)OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, NULL);
+ (void)OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS
+# if defined(OPENSSL_INIT_NO_LOAD_CONFIG) && defined(UB_ON_WINDOWS)
+ | OPENSSL_INIT_NO_LOAD_CONFIG
+# endif
+ , NULL);
#endif
do_service(addr, port, key, cert);