From a30621493fd907ddec1db25cf1840775266c99de Mon Sep 17 00:00:00 2001 From: Olaf Bergmann Date: Wed, 18 Apr 2012 12:45:27 +0200 Subject: [PATCH] bugfix (Thanks to John Sucaet) --- pdu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pdu.c b/pdu.c index e619ba71..078e4962 100644 --- a/pdu.c +++ b/pdu.c @@ -123,7 +123,8 @@ coap_add_option(coap_pdu_t *pdu, unsigned short type, unsigned int len, const un opt = options_start(pdu); cnt = pdu->hdr->optcnt; while ((pdu->hdr->optcnt == COAP_OPT_LONG && opt && - opt < data + len && *opt != COAP_OPT_END) + opt < ((unsigned char *)pdu->hdr + pdu->max_size) && + *opt != COAP_OPT_END) || cnt--) { opt_code += COAP_OPT_DELTA(opt); opt = options_next(opt);