mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-13 03:40:40 +03:00
pdu.c: Fix length check in write_{prefix,char}
Fix length check in two helper functions that have been introduced in
commit 757ca19c.
Fixes OSS-Fuzz issue 31479 [1]
[1] https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=31479
This commit is contained in:
1 parent
25db7412c5
commit
f930b0ad5b
1 file changed
+2
-2
@@ -933,7 +933,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 + 1 < prflen) {
|
||||
if (*len > prflen +1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -946,7 +946,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 + 1 < 2) {
|
||||
if (*len > 3) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user