summaryrefslogtreecommitdiffstats
path: root/common/state/backend_bucket_circular.c
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2017-07-18 15:14:45 +0200
committerLucas Stach <l.stach@pengutronix.de>2017-07-20 12:15:57 +0200
commita0c26429e472a175ac6b1736c8687a19a76e97a9 (patch)
tree1c3913feb45e9c57c5e024ce90307d1377481b69 /common/state/backend_bucket_circular.c
parente667f820eb373f221c9c220341178fe5e869d15a (diff)
downloadbarebox-a0c26429e472a175ac6b1736c8687a19a76e97a9.tar.gz
barebox-a0c26429e472a175ac6b1736c8687a19a76e97a9.tar.xz
state: backend_bucket_circular: fix old state reads
When the circular bucket meta magic was not found, it is assumed that the whole written state is in the old on-storage format. In that case, the size of the circular bucket meta must not be subtracted from the read length, or the (complete_len > len) check in the raw backend's verify function will fail: state: Error, invalid data_len 16 in header, have data of len 24 Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Diffstat (limited to 'common/state/backend_bucket_circular.c')
-rw-r--r--common/state/backend_bucket_circular.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/common/state/backend_bucket_circular.c b/common/state/backend_bucket_circular.c
index 7c81cdfaff..3dcff5cf06 100644
--- a/common/state/backend_bucket_circular.c
+++ b/common/state/backend_bucket_circular.c
@@ -279,7 +279,10 @@ static int state_backend_bucket_circular_read(struct state_backend_storage_bucke
}
*buf_out = buf;
- *len_out = read_len - sizeof(struct state_backend_storage_bucket_circular_meta);
+ /* When reading old state there is no circular bucket metadata */
+ if (circ->last_written_length)
+ read_len -= sizeof(struct state_backend_storage_bucket_circular_meta);
+ *len_out = read_len;
return ret;
}