Mercurial > libjeffpc
changeset 722:69021db0eee3
cbor: fix indefinite array & map unpacking break check
We were consuming the required break by calling cbor_unpack_break, then the
cbor_unpack_{array,map}_end call would fail since it would not find the
expected break.
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Tue, 19 Mar 2019 15:56:47 -0400 |
parents | 60e8e945b4a3 |
children | f889818f12a5 |
files | fmt_cbor.c |
diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/fmt_cbor.c Tue Mar 19 15:54:17 2019 -0400 +++ b/fmt_cbor.c Tue Mar 19 15:56:47 2019 -0400 @@ -847,10 +847,11 @@ struct val **tmparr; struct val *elem; - ret = cbor_unpack_break(buffer); + ret = cbor_peek_break(buffer); if (!ret) - break; /* end of map */ - /* TODO: check for errors */ + break; /* end of array */ + if (ret != -EILSEQ) + goto err; /* error */ elem = unpack_cbor_val(buffer); if (IS_ERR(elem)) { @@ -952,10 +953,11 @@ if (end_required) { /* indef */ for (;;) { - ret = cbor_unpack_break(buffer); + ret = cbor_peek_break(buffer); if (!ret) break; /* end of map */ - /* TODO: check for errors */ + if (ret != -EILSEQ) + goto err; /* error */ ret = __unpack_cbor_pair(buffer, nvl); if (ret)