pdu.c: Correctly check for NUL termination space when outputting bad options

This commit is contained in:
Jon Shallow authored and Jon Shallow committed 2022-11-22 09:58:36 +00:00
1 parent 64de2ba4ea
commit 11018cc34c
1 file changed
+2 -2
+2 -2
View File
@@ -1014,7 +1014,7 @@ coap_pdu_parse_opt_base(coap_pdu_t *pdu, uint16_t len) {
static int
write_prefix(char **obp, size_t *len, const char *prf, size_t prflen) {
/* Make sure space for null terminating byte */
if (*len > prflen +1) {
if (*len < prflen +1) {
return 0;
}
@@ -1027,7 +1027,7 @@ write_prefix(char **obp, size_t *len, const char *prf, size_t prflen) {
static int
write_char(char **obp, size_t *len, char c, int printable) {
/* Make sure space for null terminating byte */
if (*len > 3) {
if (*len < 2 +1) {
return 0;
}