Repository: qpid-proton Updated Branches: refs/heads/master 83bab4a08 -> b9e60cd6c
PROTON-1193: Incorrect use of getaddrinfo/socket calls - Because of inconsistent use of getaddrinfo and socket calls it was possible to attempt to create socket types that are not valid - Detected on FreeBSD Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/b9e60cd6 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/b9e60cd6 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/b9e60cd6 Branch: refs/heads/master Commit: b9e60cd6c8f3aa3176aca4aa34a7059b902c91bc Parents: 83bab4a Author: Andrew Stitcher <[email protected]> Authored: Sat May 7 01:31:49 2016 -0400 Committer: Andrew Stitcher <[email protected]> Committed: Tue May 10 10:24:16 2016 -0400 ---------------------------------------------------------------------- proton-c/src/posix/io.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b9e60cd6/proton-c/src/posix/io.c ---------------------------------------------------------------------- diff --git a/proton-c/src/posix/io.c b/proton-c/src/posix/io.c index 8b89316..3226594 100644 --- a/proton-c/src/posix/io.c +++ b/proton-c/src/posix/io.c @@ -127,7 +127,8 @@ static inline int pn_create_socket(int af, int protocol); pn_socket_t pn_listen(pn_io_t *io, const char *host, const char *port) { struct addrinfo *addr; - int code = getaddrinfo(host, port, NULL, &addr); + struct addrinfo hints = {0, AF_UNSPEC, SOCK_STREAM}; + int code = getaddrinfo(host, port, &hints, &addr); if (code) { pn_error_format(io->error, PN_ERR, "getaddrinfo(%s, %s): %s\n", host, port, gai_strerror(code)); return PN_INVALID_SOCKET; @@ -169,7 +170,8 @@ pn_socket_t pn_listen(pn_io_t *io, const char *host, const char *port) pn_socket_t pn_connect(pn_io_t *io, const char *host, const char *port) { struct addrinfo *addr; - int code = getaddrinfo(host, port, NULL, &addr); + struct addrinfo hints = {0, AF_UNSPEC, SOCK_STREAM}; + int code = getaddrinfo(host, port, &hints, &addr); if (code) { pn_error_format(io->error, PN_ERR, "getaddrinfo(%s, %s): %s", host, port, gai_strerror(code)); return PN_INVALID_SOCKET; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
