OSCORE Option: Check for off by one for kid

This commit is contained in:
Jon Shallow authored and Jon Shallow committed 2023-01-14 15:16:26 +00:00
1 parent 7623e0f085
commit 7fab8aa6fb
2 files changed
+6 -2

No files matched your search

+4 -2
View File
@@ -740,6 +740,8 @@ coap_show_pdu(coap_log_t level, const coap_pdu_t *pdu) {
}
if (opt_val[0] & 0x10) {
/* kid context */
if (ofs >= opt_len)
goto no_more;
cnt = opt_val[ofs];
if (cnt > opt_len - ofs - 1)
goto no_more;
@@ -756,9 +758,9 @@ coap_show_pdu(coap_log_t level, const coap_pdu_t *pdu) {
}
if (opt_val[0] & 0x08) {
/* kid */
cnt = opt_len - ofs;
if (cnt > opt_len - ofs)
if (ofs >= opt_len)
goto no_more;
cnt = opt_len - ofs;
buf_len = strlen((char *)buf);
snprintf((char *)&buf[buf_len], sizeof(buf)-buf_len, "%skid=0x",
buf_len ? "," : "");
+2
View File
@@ -278,6 +278,8 @@ oscore_decode_option_value(const uint8_t *opt_value,
if ((opt_value[0] & 0x10) != 0) {
coap_bin_const_t kid_context;
if (offset >= option_len)
return 0;
kid_context.length = opt_value[offset];
offset++;
if (offset + kid_context.length > option_len) {