提交 c72fb77f 编写于 作者: R Richard Levitte

Rework BIO_ADDRINFO_protocol() to return correct values

As noted already, some platforms don't fill in ai_protocol as
expected.  To circumvent that, we have BIO_ADDRINFO_protocol() to
compute a sensible answer in that case.
Reviewed-by: NKurt Roeckx <kurt@openssl.org>
上级 210ac682
...@@ -379,8 +379,24 @@ int BIO_ADDRINFO_socktype(const BIO_ADDRINFO *bai) ...@@ -379,8 +379,24 @@ int BIO_ADDRINFO_socktype(const BIO_ADDRINFO *bai)
int BIO_ADDRINFO_protocol(const BIO_ADDRINFO *bai) int BIO_ADDRINFO_protocol(const BIO_ADDRINFO *bai)
{ {
if (bai != NULL) if (bai != NULL) {
return bai->bai_protocol; if (bai->bai_protocol != 0)
return bai->bai_protocol;
#ifdef AF_UNIX
if (bai->bai_family == AF_UNIX)
return 0;
#endif
switch (bai->bai_socktype) {
case SOCK_STREAM:
return IPPROTO_TCP;
case SOCK_DGRAM:
return IPPROTO_UDP;
default:
break;
}
}
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册