summaryrefslogtreecommitdiffstats
path: root/pb_decode.c
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-02-07 17:56:52 +0200
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-02-07 17:56:52 +0200
commitc1bd1a6ad3479088fef09c02e39b70bea0a718ae (patch)
tree91072106d36dbc182a762e280619158ba92f3487 /pb_decode.c
parente7bf063abc2ca3a46c778e0194f0e8d4ef1a5168 (diff)
Fix error message bugs with packed arrays.
Error messages were not propagated correctly with PB_HTYPE_ARRAY. Error status (boolean return value) was correct. Update issue 56 Status: FixedInGit
Diffstat (limited to 'pb_decode.c')
-rw-r--r--pb_decode.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/pb_decode.c b/pb_decode.c
index b25f3f55..d4741130 100644
--- a/pb_decode.c
+++ b/pb_decode.c
@@ -361,7 +361,7 @@ static bool checkreturn decode_field(pb_istream_t *stream, pb_wire_type_t wire_t
&& PB_LTYPE(iter->current->type) <= PB_LTYPE_LAST_PACKABLE)
{
/* Packed array */
- bool status;
+ bool status = true;
size_t *size = (size_t*)iter->pSize;
pb_istream_t substream;
if (!pb_make_string_substream(stream, &substream))
@@ -371,11 +371,17 @@ static bool checkreturn decode_field(pb_istream_t *stream, pb_wire_type_t wire_t
{
void *pItem = (uint8_t*)iter->pData + iter->current->data_size * (*size);
if (!func(&substream, iter->current, pItem))
- return false;
+ {
+ status = false;
+ break;
+ }
(*size)++;
}
- status = (substream.bytes_left == 0);
pb_close_string_substream(stream, &substream);
+
+ if (substream.bytes_left != 0)
+ PB_RETURN_ERROR(stream, "array overflow");
+
return status;
}
else