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.
This commit is contained in:
Jon Shallow authored and Jon Shallow committed 2022-12-26 10:49:20 +00:00
1 parent 7aa003bbe7
commit 088fff1a82
1 file changed
+1 -1
+1 -1
View File
@@ -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)