summaryrefslogtreecommitdiffstats
path: root/common/state/backend_format_raw.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-03-23 09:16:14 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-03-31 18:43:53 +0200
commit9948003da46c27b45d4479124407ed7805d84a02 (patch)
tree8eaca5b4873abd1b957b3cfe729b066b3ec9a60e /common/state/backend_format_raw.c
parentb7d9863dae31d7d4d3d4a9d671c4595287243b98 (diff)
downloadbarebox-9948003da46c27b45d4479124407ed7805d84a02.tar.gz
state: replace len_hint logic
The len_hint mechanism is rather hard to understand as it's not clear from where to where the hint is passed and also it's not clear what happens if the hint is empty or wrong. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/state/backend_format_raw.c')
-rw-r--r--common/state/backend_format_raw.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/common/state/backend_format_raw.c b/common/state/backend_format_raw.c
index e028ea6..3c8956f 100644
--- a/common/state/backend_format_raw.c
+++ b/common/state/backend_format_raw.c
@@ -55,13 +55,14 @@ static inline struct state_backend_format_raw *get_format_raw(
static int backend_format_raw_verify(struct state_backend_format *format,
uint32_t magic, const uint8_t * buf,
- ssize_t len)
+ ssize_t *lenp)
{
uint32_t crc;
struct backend_raw_header *header;
int d_len = 0;
int ret;
const uint8_t *data;
+ ssize_t len = *lenp;
struct state_backend_format_raw *backend_raw = get_format_raw(format);
ssize_t complete_len;
@@ -105,6 +106,8 @@ static int backend_format_raw_verify(struct state_backend_format *format,
return -EINVAL;
}
+ *lenp = header->data_len + sizeof(*header);
+
if (backend_raw->digest) {
struct digest *d = backend_raw->digest;
const void *hmac = data + header->data_len;