Fixed issue 1 reported by Erik Rosen:

The size of non-callback bytes-fields was miscalculated, which
caused all following fields in a message to contain garbage.

Previous commit contains a testcase for this.

This fix changes the generated message description. If your protocol uses
bytes-fields, you should regenerate *.pb.c.
This commit is contained in:
Petteri Aimonen
2012-01-12 19:08:05 +02:00
parent 0f6b615ae3
commit 113bd7ee87
4 changed files with 17 additions and 7 deletions

View File

@@ -509,7 +509,8 @@ bool checkreturn pb_dec_bytes(pb_istream_t *stream, const pb_field_t *field, voi
return false;
x->size = temp;
if (x->size > field->data_size)
/* Check length, noting the space taken by the size_t header. */
if (x->size > field->data_size - offsetof(pb_bytes_array_t, bytes))
return false;
return pb_read(stream, x->bytes, x->size);
@@ -522,6 +523,7 @@ bool checkreturn pb_dec_string(pb_istream_t *stream, const pb_field_t *field, vo
if (!pb_decode_varint32(stream, &size))
return false;
/* Check length, noting the null terminator */
if (size > field->data_size - 1)
return false;