From f5251e682ce385d6267251e3fe2be57c18d5c09d Mon Sep 17 00:00:00 2001 From: Jon Shallow Date: Tue, 18 Oct 2022 14:45:18 +0100 Subject: [PATCH] coap-client.c: Validate input block sizes --- examples/coap-client.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/examples/coap-client.c b/examples/coap-client.c index c6c44914..c8ad16ee 100644 --- a/examples/coap-client.c +++ b/examples/coap-client.c @@ -785,6 +785,16 @@ cmdline_blocksize(char *arg) { goto again; } + if (size < 16) { + coap_log(LOG_WARNING, "Minimum block size is 16\n"); + return 0; + } else if (size > 1024) { + coap_log(LOG_WARNING, "Maximum block size is 1024\n"); + return 0; + } else if ((size % 16) != 0 ){ + coap_log(LOG_WARNING, "Block size %u is not a multiple of 16\n", size); + return 0; + } if (size) block.szx = (coap_fls(size >> 4) - 1) & 0x07;