diff options
author | Petteri Aimonen <jpa@npb.mail.kapsi.fi> | 2011-08-22 18:57:23 +0000 |
---|---|---|
committer | Petteri Aimonen <jpa@npb.mail.kapsi.fi> | 2011-08-22 18:57:23 +0000 |
commit | 5a9f85b87615078868d3b394370a30b550186cce (patch) | |
tree | fd2b911a5708f341fcf2b839d05e8e5653bd99ab /pb_decode.c | |
parent | 494fbd91e4e5574a4cf8dbe69b3f80a08e97e85b (diff) |
unittests, change to PB_LTYPE_BYTES data size
git-svn-id: https://svn.kapsi.fi/jpa/nanopb@959 e3a754e5-d11d-0410-8d38-ebb782a927b9
Diffstat (limited to 'pb_decode.c')
-rw-r--r-- | pb_decode.c | 6 |
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); |