diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-11-03 08:29:55 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-11-03 08:30:34 -0800 |
| commit | 8249242a9325a27e57107d78bfa168e918cc4f7a (patch) | |
| tree | 3fa7a7a0dd66c23684b731f6b2686e9b6ea7a574 /tests/ws.c | |
| parent | a5807e45b1badfb5d0cb4f697e1873a8ece59a30 (diff) | |
| download | nng-8249242a9325a27e57107d78bfa168e918cc4f7a.tar.gz nng-8249242a9325a27e57107d78bfa168e918cc4f7a.tar.bz2 nng-8249242a9325a27e57107d78bfa168e918cc4f7a.zip | |
Remove untyped nng_pipe_get, support for untyped sockaddr set.
This is a step on the path to removing unsafe untyped option accesses.
Diffstat (limited to 'tests/ws.c')
| -rw-r--r-- | tests/ws.c | 30 |
1 files changed, 3 insertions, 27 deletions
@@ -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); |
