Fix s_client hang on non-compliant NNTP server test

Fixes #7722

CLA: trivial

Signed-off-by: Mateja Milosevic <quantumgleam@gmail.com>

Reviewed-by: Paul Yang <yang.yang@baishancloud.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/7915)
This commit is contained in:
Quantomicus 2018-12-17 17:26:29 +01:00
parent fc5ecaddd0
commit 5aa2a7ea41

View file

@ -2535,12 +2535,16 @@ int s_client_main(int argc, char **argv)
/* STARTTLS command requires CAPABILITIES... */
BIO_printf(fbio, "CAPABILITIES\r\n");
(void)BIO_flush(fbio);
/* wait for multi-line CAPABILITIES response */
do {
mbuf_len = BIO_gets(fbio, mbuf, BUFSIZZ);
if (strstr(mbuf, "STARTTLS"))
foundit = 1;
} while (mbuf_len > 1 && mbuf[0] != '.');
BIO_gets(fbio, mbuf, BUFSIZZ);
/* no point in trying to parse the CAPABILITIES response if there is none */
if (strstr(mbuf, "101") != NULL) {
/* wait for multi-line CAPABILITIES response */
do {
mbuf_len = BIO_gets(fbio, mbuf, BUFSIZZ);
if (strstr(mbuf, "STARTTLS"))
foundit = 1;
} while (mbuf_len > 1 && mbuf[0] != '.');
}
(void)BIO_flush(fbio);
BIO_pop(fbio);
BIO_free(fbio);