aboutsummaryrefslogtreecommitdiff
path: root/crypto/bio
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2016-02-10 22:33:44 +0100
committerRichard Levitte <levitte@openssl.org>2016-02-11 14:13:01 +0100
commitc72fb77ff2644cf7edc9821a431c2faf123d4daf (patch)
treece5d7402596221ea9f2e6333afb4a5b838b40f82 /crypto/bio
parent210ac6824670b4d207f6ea7257d21adb44986ee4 (diff)
downloadopenssl-c72fb77ff2644cf7edc9821a431c2faf123d4daf.zip
openssl-c72fb77ff2644cf7edc9821a431c2faf123d4daf.tar.gz
openssl-c72fb77ff2644cf7edc9821a431c2faf123d4daf.tar.bz2
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: Kurt Roeckx <kurt@openssl.org>
Diffstat (limited to 'crypto/bio')
-rw-r--r--crypto/bio/b_addr.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/crypto/bio/b_addr.c b/crypto/bio/b_addr.c
index 9131dcd..459443b 100644
--- a/crypto/bio/b_addr.c
+++ b/crypto/bio/b_addr.c
@@ -379,8 +379,24 @@ int BIO_ADDRINFO_socktype(const BIO_ADDRINFO *bai)
int BIO_ADDRINFO_protocol(const BIO_ADDRINFO *bai)
{
- if (bai != NULL)
- return bai->bai_protocol;
+ if (bai != NULL) {
+ 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;
}