From 9f14450a7ede9da347e27648da793fb8698c6e57 Mon Sep 17 00:00:00 2001 From: Jon Shallow Date: Thu, 14 May 2026 14:56:18 +0100 Subject: [PATCH] coap_subscribe.c: Fix issue found by oss-fuzz --- include/coap3/coap_resource_internal.h | 2 +- src/coap_subscribe.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/coap3/coap_resource_internal.h b/include/coap3/coap_resource_internal.h index b094afda..7b8ddf20 100644 --- a/include/coap3/coap_resource_internal.h +++ b/include/coap3/coap_resource_internal.h @@ -256,7 +256,7 @@ coap_print_status_t coap_print_wellknown_lkd(coap_context_t *context, /** * Check to see if a dynamic resource needs to be added. * - * @param session Session potentiall adding a new dynamic resource. + * @param session Session potentially adding a new dynamic resource. * @param pdu PDU that is asking for an unknown resource. * * @return Created resource or NULL is resource eneration not applicable. diff --git a/src/coap_subscribe.c b/src/coap_subscribe.c index 33483dc7..5b497e38 100644 --- a/src/coap_subscribe.c +++ b/src/coap_subscribe.c @@ -979,7 +979,8 @@ coap_op_dyn_resource_load_disk(coap_context_t *ctx) { raw_packet->length, request)) { goto fail; } - if (!COAP_PDU_IS_REQUEST(request)) { + if (request->code == 0 || request->code > 7) { + /* Need to protect r->handler[request->code-1] */ goto next; } r = coap_add_dynamic_resource(session, request);