mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-04 08:55:40 +03:00
coap_address.c: Validate length of provided host name
Host names larger than 255 bytes will cause an internal buffer overflow. Hostnames provided to coap_resolve_address_info() now have their length validated. Discovered by SecMate (https://secmate.dev). Sanity check host lengths when parsing a CoAP URI when using the coap_split_uri() function.
This commit is contained in:
1 parent
1cae046728
commit
30db3eaa1f
3 files changed
+32
-8
No files matched your search
@@ -912,6 +912,12 @@ cmdline_tls_engine(char *arg) {
|
||||
static int
|
||||
cmdline_uri(char *arg) {
|
||||
|
||||
/* Sanity check the provided (Proxy)Uri */
|
||||
if (coap_split_uri((unsigned char *)arg, strlen(arg), &uri) < 0) {
|
||||
coap_log_err("invalid CoAP URI '%s'\n", arg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!proxy_scheme_option && proxy.host.length) {
|
||||
/* create Proxy-Uri from argument */
|
||||
size_t len = strlen(arg);
|
||||
@@ -926,11 +932,6 @@ cmdline_uri(char *arg) {
|
||||
(unsigned char *)arg));
|
||||
|
||||
} else { /* split arg into Uri-* options */
|
||||
if (coap_split_uri((unsigned char *)arg, strlen(arg), &uri) < 0) {
|
||||
coap_log_err("invalid CoAP URI '%s'\n", arg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Need to special case use of reliable */
|
||||
if (uri.scheme == COAP_URI_SCHEME_COAPS && reliable) {
|
||||
if (!coap_tls_is_supported()) {
|
||||
|
||||
Reference in new issue
Block a user