From 088fff1a82a760d9e49288dbda9215cbeff936f0 Mon Sep 17 00:00:00 2001 From: Jon Shallow Date: Fri, 23 Dec 2022 15:07:58 +0000 Subject: [PATCH] coap-client.c: Fix case when no host is specified in the URI If the host has not been specified in the URI, do not add in an empty Uri-Host option as that is illegal. --- examples/coap-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/coap-client.c b/examples/coap-client.c index 2ebeb4dd..44c00000 100644 --- a/examples/coap-client.c +++ b/examples/coap-client.c @@ -1746,7 +1746,7 @@ main(int argc, char **argv) { /* construct CoAP message */ - if (!uri_host_option && (!proxy.host.length && addrptr + if (!uri_host_option && (!proxy.host.length && uri.host.length && addrptr && (inet_ntop(dst.addr.sa.sa_family, addrptr, addr, sizeof(addr)) != 0) && (strlen(addr) != uri.host.length || memcmp(addr, uri.host.s, uri.host.length) != 0)