summaryrefslogtreecommitdiffstats
path: root/common/state
diff options
context:
space:
mode:
authorUlrich Ölmann <u.oelmann@pengutronix.de>2019-02-08 08:15:26 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-02-11 09:12:36 +0100
commit5033b4f58f71e1535ab83d35dfcd8bb1b0384e22 (patch)
tree5a8915aa8bac28837731806334e3e8241af79794 /common/state
parentb525657cd5360a4737df9c09169ef54d33420a99 (diff)
downloadbarebox-5033b4f58f71e1535ab83d35dfcd8bb1b0384e22.tar.gz
common: state: harmonize code with dt-utils
Insert a helpful size check that is an outcome of the following dt-utils commits: | commit a6eb5350be0f7a5673162d20f2dd72569d5a4d0c | Author: Markus Pargmann <mpa@pengutronix.de> | Date: Fri May 27 13:53:40 2016 +0200 | | barebox-state: Import updated state code | | Signed-off-by: Markus Pargmann <mpa@pengutronix.de> | commit 583acea6669550ffa7ffb465301ddb3529206afc | Author: Sascha Hauer <s.hauer@pengutronix.de> | Date: Thu Mar 23 11:29:50 2017 +0100 | | state: backend-direct: Fix max_size | | The max_size in the direct backend includes the meta data, so | substract its size when determing the max data size we can store. | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> | commit dcf781f1b3d15aff5f5ff0b604bff447dee2040c | Author: Sascha Hauer <s.hauer@pengutronix.de> | Date: Thu Mar 23 12:59:48 2017 +0100 | | state: backend_bucket_direct: max_size is always given | | max_size is always != 0, so if(direct->max_size) can be skipped. | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/state')
-rw-r--r--common/state/backend_bucket_direct.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c
index 9d6a337..1f00b0f 100644
--- a/common/state/backend_bucket_direct.c
+++ b/common/state/backend_bucket_direct.c
@@ -110,6 +110,9 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket
int ret;
struct state_backend_storage_bucket_direct_meta meta;
+ if (len > direct->max_size - sizeof(meta))
+ return -E2BIG;
+
ret = lseek(direct->fd, direct->offset, SEEK_SET);
if (ret < 0) {
dev_err(direct->dev, "Failed to seek file, %d\n", ret);