From d9de7a68b60caea4586ac9ab494f0e90bca2cc9f Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Thu, 19 Oct 2023 07:37:45 -0400 Subject: [PATCH 1/2] Fix getaddrinfo_valid: ask for SOCK_STREAM Since we test that the results are of type SOCK_STREAM, we need to ask for that in the hints to getaddrinfo. --- tests/socket-api-tests.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/socket-api-tests.c b/tests/socket-api-tests.c index 722e037..8b08672 100644 --- a/tests/socket-api-tests.c +++ b/tests/socket-api-tests.c @@ -985,7 +985,10 @@ void assert_addrinfo(struct addrinfo* rp, int exp_socktype, short exp_port) START_TEST(getaddrinfo_valid) { struct addrinfo *rp, *res = NULL; - struct addrinfo hints = {.ai_family = AF_UNSPEC}; + struct addrinfo hints = { + .ai_family = AF_UNSPEC, + .ai_socktype = SOCK_STREAM + }; ck_assert(mm_getaddrinfo("localhost", "ssh", &hints, &res) == 0); for (rp = res; rp != NULL; rp = rp->ai_next) From 9a9a70b6a89c90170a0bb215185ab4dd299eec4c Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Thu, 19 Oct 2023 07:46:11 -0400 Subject: [PATCH 2/2] Fix getaddrinfo_error: ask for SOCK_RAW Since getaddrinfo may offer results of type SOCK_DGRAM, we ask for something more difficult (but still a valid socket type). --- tests/socket-api-tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/socket-api-tests.c b/tests/socket-api-tests.c index 8b08672..5e133f6 100644 --- a/tests/socket-api-tests.c +++ b/tests/socket-api-tests.c @@ -1016,7 +1016,7 @@ START_TEST(getaddrinfo_error) ck_assert(mm_getaddrinfo("localhost", "joke", &hints, &res) == -1); ck_assert_int_eq(mm_get_lasterror_number(), MM_ENOTFOUND); - hints.ai_socktype = SOCK_DGRAM; + hints.ai_socktype = SOCK_RAW; ck_assert(mm_getaddrinfo("localhost", "ssh", &hints, &res) == -1); ck_assert_int_eq(mm_get_lasterror_number(), MM_ENOTFOUND); hints.ai_socktype = 0;