New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
s_server: Report an error if init-connection fails without an attempt to read #18154
Conversation
note the typo in the commit message |
Have you verified that this won't break s_server if for example in dtls mode if client sends some broken client hello or some combination of algorithms the server does not support? |
2deda1d
to
923d521
Compare
There is one more way how you could possibly solve this issue. Set a callback function on the read bio with BIO_set_callback_ex() and if the callback is not called during the init connection call, it means the failure does not have anything with the connection attempt. |
dc93512
to
3445859
Compare
3445859
to
85e987e
Compare
apps/s_server.c
Outdated
|
||
if (s_debug) { | ||
BIO_set_callback_arg(bio, (char* )bio_s_out); | ||
bio_dump_callback(bio, cmd, argp, len, argi, argl, ret, processed); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although the bio_dump_callback() does not modify the ret value we should do here ret = (int)bio_dump....
apps/s_server.c
Outdated
if (s_debug) { | ||
BIO_set_callback_arg(bio, (char* )bio_s_out); | ||
bio_dump_callback(bio, cmd, argp, len, argi, argl, ret, processed); | ||
BIO_set_callback_arg(bio, (char* )p_counter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be (char *)
apps/s_server.c
Outdated
static long count_reads_callback(BIO *bio, int cmd, const char *argp, size_t len, | ||
int argi, long argl, int ret, size_t *processed) | ||
{ | ||
unsigned *p_counter = (unsigned*)BIO_get_callback_arg(bio); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(unsigned *)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this unsigned int *
rather than just unsigned *
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Some minor nits below
apps/s_server.c
Outdated
} | ||
|
||
if (s_debug) { | ||
BIO_set_callback_arg(bio, (char* )bio_s_out); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(char *)
apps/s_server.c
Outdated
static long count_reads_callback(BIO *bio, int cmd, const char *argp, size_t len, | ||
int argi, long argl, int ret, size_t *processed) | ||
{ | ||
unsigned *p_counter = (unsigned*)BIO_get_callback_arg(bio); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this unsigned int *
rather than just unsigned *
apps/s_server.c
Outdated
* It helps us to recognise configuration errors and errors | ||
* caused by a client. | ||
*/ | ||
unsigned read_counter = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsigned int read_counter = 0;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with the style nits fixed and possible with the changed comment (or a not changed comment).
apps/s_server.c
Outdated
@@ -2328,6 +2328,30 @@ static void print_stats(BIO *bio, SSL_CTX *ssl_ctx) | |||
SSL_CTX_sess_get_cache_size(ssl_ctx)); | |||
} | |||
|
|||
static long count_reads_callback(BIO *bio, int cmd, const char *argp, size_t len, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're being pedantic about the int part: long int
.
@faramir-dev ping for fixups |
@paulidale still OK? |
This pull request is ready to merge |
Merged to master and 3.0 branches. Thank you. It needs adjustments for 1.1.1. @faramir-dev could you please create a backported PR for 1.1.1? |
…connection.
Fixes #18047.
Checklist