sys/net/nanocoap: return ENOENT if parsing option failed
This fixes a potential use of uninitialized len in subsequent function calls. This was reported by scan-build
This commit is contained in:
parent
5b4b12ed07
commit
1aa1e2c8cc
@ -586,6 +586,7 @@ ssize_t coap_opt_get_next(const coap_pkt_t *pkt, coap_optpos_t *opt,
|
|||||||
*
|
*
|
||||||
* @return length of option; 0 if the option exists but is empty
|
* @return length of option; 0 if the option exists but is empty
|
||||||
* @return -ENOENT if option not found
|
* @return -ENOENT if option not found
|
||||||
|
* @return -EINVAL if option cannot be parsed
|
||||||
*/
|
*/
|
||||||
ssize_t coap_opt_get_opaque(coap_pkt_t *pkt, unsigned opt_num, uint8_t **value);
|
ssize_t coap_opt_get_opaque(coap_pkt_t *pkt, unsigned opt_num, uint8_t **value);
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|||||||
@ -217,6 +217,10 @@ ssize_t coap_opt_get_opaque(coap_pkt_t *pkt, unsigned opt_num, uint8_t **value)
|
|||||||
int len;
|
int len;
|
||||||
|
|
||||||
*value = _parse_option(pkt, start, &delta, &len);
|
*value = _parse_option(pkt, start, &delta, &len);
|
||||||
|
if (!*value) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user