[PATCH 7/7] common: state: harmonize code with dt-utils

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Insert a helpful size check that is an outcome of the following dt-utils
commits:

| commit a6eb5350be0f7a5673162d20f2dd72569d5a4d0c
| Author: Markus Pargmann <mpa@xxxxxxxxxxxxxx>
| Date:   Fri May 27 13:53:40 2016 +0200
|
|     barebox-state: Import updated state code
|
|     Signed-off-by: Markus Pargmann <mpa@xxxxxxxxxxxxxx>

| commit 583acea6669550ffa7ffb465301ddb3529206afc
| Author: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
| 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@xxxxxxxxxxxxxx>

| commit dcf781f1b3d15aff5f5ff0b604bff447dee2040c
| Author: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
| 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@xxxxxxxxxxxxxx>

Signed-off-by: Ulrich Ölmann <u.oelmann@xxxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux