Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nanopb/nanopb.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'pb_decode.c')
-rw-r--r--pb_decode.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/pb_decode.c b/pb_decode.c
index 2cde54c..9208bda 100644
--- a/pb_decode.c
+++ b/pb_decode.c
@@ -73,7 +73,7 @@ static bool pb_decode_varint32(pb_istream_t *stream, uint32_t *dest)
bool pb_decode_varint(pb_istream_t *stream, uint64_t *dest)
{
uint8_t byte;
- int bitpos = 0;
+ uint8_t bitpos = 0;
*dest = 0;
while (bitpos < 64 && pb_read(stream, &byte, 1))
@@ -460,9 +460,7 @@ bool pb_dec_bytes(pb_istream_t *stream, const pb_field_t *field, void *dest)
return false;
x->size = temp;
- /* Note: data_size includes the size of the x.size field, too.
- * Calculate actual size starting from offset. */
- if (x->size > field->data_size - offsetof(pb_bytes_array_t, bytes))
+ if (x->size > field->data_size)
return false;
return pb_read(stream, x->bytes, x->size);