From 8249242a9325a27e57107d78bfa168e918cc4f7a Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 3 Nov 2024 08:29:55 -0800 Subject: Remove untyped nng_pipe_get, support for untyped sockaddr set. This is a step on the path to removing unsafe untyped option accesses. --- tests/ws.c | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) (limited to 'tests/ws.c') diff --git a/tests/ws.c b/tests/ws.c index d2ae7f9b..041fe4d0 100644 --- a/tests/ws.c +++ b/tests/ws.c @@ -23,11 +23,9 @@ static int check_props_v4(nng_msg *msg) { nng_pipe p; - size_t z; nng_sockaddr la; nng_sockaddr ra; char *buf; - size_t len; p = nng_msg_get_pipe(msg); So(nng_pipe_id(p) > 0); @@ -38,42 +36,20 @@ check_props_v4(nng_msg *msg) So(la.s_in.sa_port != 0); So(la.s_in.sa_addr == htonl(0x7f000001)); - z = sizeof(nng_sockaddr); - So(nng_pipe_get(p, NNG_OPT_REMADDR, &ra, &z) == 0); - So(z == sizeof(ra)); + So(nng_pipe_get_addr(p, NNG_OPT_REMADDR, &ra) == 0); So(ra.s_family == NNG_AF_INET); So(ra.s_in.sa_port != 0); So(ra.s_in.sa_addr == htonl(0x7f000001)); // Request Header - z = 0; buf = NULL; - So(nng_pipe_get(p, NNG_OPT_WS_REQUEST_HEADERS, buf, &z) == NNG_EINVAL); - So(z > 0); - len = z; - So((buf = nng_alloc(len)) != NULL); - So(nng_pipe_get(p, NNG_OPT_WS_REQUEST_HEADERS, buf, &z) == 0); - So(strstr(buf, "Sec-WebSocket-Key") != NULL); - So(z == len); - nng_free(buf, len); So(nng_pipe_get_string(p, NNG_OPT_WS_REQUEST_HEADERS, &buf) == 0); - So(strlen(buf) == len - 1); + So(strstr(buf, "Sec-WebSocket-Key") != NULL); nng_strfree(buf); // Response Header - z = 0; - buf = NULL; - So(nng_pipe_get(p, NNG_OPT_WS_RESPONSE_HEADERS, buf, &z) == - NNG_EINVAL); - So(z > 0); - len = z; - So((buf = nng_alloc(len)) != NULL); - So(nng_pipe_get(p, NNG_OPT_WS_RESPONSE_HEADERS, buf, &z) == 0); - So(strstr(buf, "Sec-WebSocket-Accept") != NULL); - So(z == len); - nng_free(buf, len); So(nng_pipe_get_string(p, NNG_OPT_WS_RESPONSE_HEADERS, &buf) == 0); - So(strlen(buf) == len - 1); + So(strstr(buf, "Sec-WebSocket-Accept") != NULL); nng_strfree(buf); return (0); -- cgit v1.2.3-70-g09d2