bugfix in option length encoding (pointed out by Timm Decker)

This commit is contained in:
Olaf Bergmann committed 2012-12-21 16:21:05 +01:00
1 parent d9eb6dc70e
commit 9f31ab3212
2 files changed
+6 -5

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@
# README for terms of use.
AC_PREREQ([2.65])
AC_INIT([libcoap], [3.0.0])
AC_INIT([libcoap], [3.0.1])
AC_CONFIG_SRCDIR([coap.h])
# First check for Contiki build to quit configure before any other test
+5 -4
View File
@@ -184,7 +184,7 @@ coap_opt_value(coap_opt_t *opt) {
while (*++p == 0xff && n++ < 3)
;
return p;
return ++p; /* point to next byte after length indicator */
}
size_t
@@ -221,9 +221,10 @@ coap_opt_setlength(coap_opt_t *opt, size_t maxlen, size_t length) {
if (maxlen <= res)
return 0;
opt++;
memset(opt, 0xff, res);
*opt = length & 0xff;
memset(opt, 0xff, res-1);
opt[res] = length & 0xff;
++res;
}
return res;