From: bluhm Date: Wed, 7 Feb 2018 00:52:05 +0000 (+0000) Subject: Restore the old behavior when a port number without a host name is X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9eb1373e44333a68d15c5e42b2125c6f83b6e089;p=openbsd Restore the old behavior when a port number without a host name is passed to BIO_get_accept_socket(). This is part of the API and it fixes "openssl ocsp -port 12345" in server mode. from markus@; OK jsing@ beck@ --- diff --git a/lib/libcrypto/bio/b_sock.c b/lib/libcrypto/bio/b_sock.c index cfa48c68602..152b0809022 100644 --- a/lib/libcrypto/bio/b_sock.c +++ b/lib/libcrypto/bio/b_sock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: b_sock.c,v 1.68 2018/02/06 14:45:52 bluhm Exp $ */ +/* $OpenBSD: b_sock.c,v 1.69 2018/02/07 00:52:05 bluhm Exp $ */ /* * Copyright (c) 2017 Bob Beck * @@ -134,16 +134,18 @@ BIO_get_accept_socket(char *host, int bind_mode) p = NULL; h = str; if ((p = strrchr(str, ':')) == NULL) { - BIOerror(BIO_R_NO_PORT_SPECIFIED); - goto err; - } - *p++ = '\0'; - if (*p == '\0') { - BIOerror(BIO_R_NO_PORT_SPECIFIED); - goto err; - } - if (*h == '\0' || strcmp(h, "*") == 0) + /* A string without a colon is treated as a port. */ + p = str; h = NULL; + } else { + *p++ = '\0'; + if (*p == '\0') { + BIOerror(BIO_R_NO_PORT_SPECIFIED); + goto err; + } + if (*h == '\0' || strcmp(h, "*") == 0) + h = NULL; + } if ((error = getaddrinfo(h, p, &hints, &res)) != 0) { ERR_asprintf_error_data("getaddrinfo: '%s:%s': %s'", h, p,