diff --git a/sys/cbor/cbor.c b/sys/cbor/cbor.c
index a1aa5affea87cf5af970180ac987956f8be363c3..05a918cd38b6dab04fc3fc604f0576bd133e6bc0 100644
--- a/sys/cbor/cbor.c
+++ b/sys/cbor/cbor.c
@@ -400,7 +400,7 @@ static size_t decode_bytes(const cbor_stream_t *s, size_t offset, char *out, siz
         return 0;
     }
 
-    if (length < bytes_length + 1) {
+    if (bytes_length == SIZE_MAX || length < bytes_length + 1) {
         return 0;
     }