summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlrich Ölmann <u.oelmann@pengutronix.de>2018-12-18 14:57:41 +0100
committerRoland Hieber <rhi@pengutronix.de>2019-01-07 12:26:50 +0100
commitf1ae2364a21432237c779e4cc04822eabb76e955 (patch)
tree3806f7d078c8e33ce73c29383ef26c11040410a4
parentd74c4e26d50538c92c90d42effe1a7e2c78a1298 (diff)
downloaddt-utils-f1ae2364a21432237c779e4cc04822eabb76e955.tar.gz
dt-utils-f1ae2364a21432237c779e4cc04822eabb76e955.tar.xz
state: backend_bucket_circular: fix old state reads
This ports the following barebox commit: | commit a0c26429e472a175ac6b1736c8687a19a76e97a9 | Author: Philipp Zabel <p.zabel@pengutronix.de> | Date: Tue Jul 18 15:14:45 2017 +0200 | | 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> Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> Signed-off-by: Roland Hieber <rhi@pengutronix.de>
-rw-r--r--src/barebox-state/backend_bucket_circular.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/barebox-state/backend_bucket_circular.c b/src/barebox-state/backend_bucket_circular.c
index ec16df2..dd609aa 100644
--- a/src/barebox-state/backend_bucket_circular.c
+++ b/src/barebox-state/backend_bucket_circular.c
@@ -280,7 +280,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;
}