Commit 645017ca authored by Lubomir Bulej's avatar Lubomir Bulej

Bump protobuf-c to version 1.3.2

parent ef59121e
......@@ -2072,6 +2072,11 @@ parse_tag_and_wiretype(size_t len,
unsigned shift = 4;
unsigned rv;
/* 0 is not a valid tag value */
if ((data[0] & 0xf8) == 0) {
return 0;
}
*wiretype_out = data[0] & 7;
if ((data[0] & 0x80) == 0) {
*tag_out = tag;
......@@ -2103,18 +2108,18 @@ struct _ScannedMember {
const uint8_t *data; /**< Pointer to field data. */
};
static inline uint32_t
static inline size_t
scan_length_prefixed_data(size_t len, const uint8_t *data,
size_t *prefix_len_out)
{
unsigned hdr_max = len < 5 ? len : 5;
unsigned hdr_len;
uint32_t val = 0;
size_t val = 0;
unsigned i;
unsigned shift = 0;
for (i = 0; i < hdr_max; i++) {
val |= (data[i] & 0x7f) << shift;
val |= ((size_t)data[i] & 0x7f) << shift;
shift += 7;
if ((data[i] & 0x80) == 0)
break;
......@@ -2125,8 +2130,15 @@ scan_length_prefixed_data(size_t len, const uint8_t *data,
}
hdr_len = i + 1;
*prefix_len_out = hdr_len;
if (val > INT_MAX) {
// Protobuf messages should always be less than 2 GiB in size.
// We also want to return early here so that hdr_len + val does
// not overflow on 32-bit systems.
PROTOBUF_C_UNPACK_ERROR("length prefix of %lu is too large", val);
return 0;
}
if (hdr_len + val > len) {
PROTOBUF_C_UNPACK_ERROR("data too short after length-prefix of %u", val);
PROTOBUF_C_UNPACK_ERROR("data too short after length-prefix of %lu", val);
return 0;
}
return hdr_len + val;
......@@ -2629,6 +2641,8 @@ parse_oneof_member (ScannedMember *scanned_member,
/* If we have already parsed a member of this oneof, free it. */
if (*oneof_case != 0) {
const ProtobufCFieldDescriptor *old_field;
size_t el_size;
/* lookup field */
int field_index =
int_range_lookup(message->descriptor->n_field_ranges,
......@@ -2636,9 +2650,8 @@ parse_oneof_member (ScannedMember *scanned_member,
*oneof_case);
if (field_index < 0)
return FALSE;
const ProtobufCFieldDescriptor *old_field =
message->descriptor->fields + field_index;
size_t el_size = sizeof_elt_in_repeated_array(old_field->type);
old_field = message->descriptor->fields + field_index;
el_size = sizeof_elt_in_repeated_array(old_field->type);
switch (old_field->type) {
case PROTOBUF_C_TYPE_STRING: {
......@@ -3415,6 +3428,13 @@ protobuf_c_message_check(const ProtobufCMessage *message)
ProtobufCLabel label = f->label;
void *field = STRUCT_MEMBER_P (message, f->offset);
if (f->flags & PROTOBUF_C_FIELD_FLAG_ONEOF) {
const uint32_t *oneof_case = STRUCT_MEMBER_P (message, f->quantifier_offset);
if (f->id != *oneof_case) {
continue; //Do not check if it is an unpopulated oneof member.
}
}
if (label == PROTOBUF_C_LABEL_REPEATED) {
size_t *quantity = STRUCT_MEMBER_P (message, f->quantifier_offset);
......
......@@ -790,13 +790,13 @@ protobuf_c_version_number(void);
* The version of the protobuf-c headers, represented as a string using the same
* format as protobuf_c_version().
*/
#define PROTOBUF_C_VERSION "1.3.1"
#define PROTOBUF_C_VERSION "1.3.2"
/**
* The version of the protobuf-c headers, represented as an integer using the
* same format as protobuf_c_version_number().
*/
#define PROTOBUF_C_VERSION_NUMBER 1003001
#define PROTOBUF_C_VERSION_NUMBER 1003002
/**
* The minimum protoc-c version which works with the current version of the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment