From: "Ulrich Ölmann" <u.oelmann@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 7/7] common: state: harmonize code with dt-utils
Date: Fri, 8 Feb 2019 08:15:26 +0100 [thread overview]
Message-ID: <20190208071526.19150-8-u.oelmann@pengutronix.de> (raw)
In-Reply-To: <20190208071526.19150-1-u.oelmann@pengutronix.de>
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>
---
common/state/backend_bucket_direct.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c
index 9d6a337e6662..1f00b0fb2f64 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);
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2019-02-08 7:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-08 7:15 [PATCH 0/7] Harmonize barebox' and dt-utils' state code Ulrich Ölmann
2019-02-08 7:15 ` [PATCH 1/7] common: state: fix compiler warnings about wrong type conversion in messages Ulrich Ölmann
2019-02-08 7:15 ` [PATCH 2/7] common: state: fix formatting of "off_t" variables Ulrich Ölmann
2019-02-08 7:15 ` [PATCH 3/7] common: state: fix formatting of "uint32_t" variables Ulrich Ölmann
2019-02-08 7:15 ` [PATCH 4/7] common: state: harmonize code with dt-utils Ulrich Ölmann
2019-02-08 7:15 ` [PATCH 5/7] " Ulrich Ölmann
2019-02-08 7:15 ` [PATCH 6/7] " Ulrich Ölmann
2019-02-08 7:15 ` Ulrich Ölmann [this message]
2019-02-11 8:12 ` [PATCH 0/7] Harmonize barebox' and dt-utils' state code Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190208071526.19150-8-u.oelmann@pengutronix.de \
--to=u.oelmann@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox