From: Sascha Hauer <s.hauer@pengutronix.de>
To: Jan Remmet <j.remmet@phytec.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] common: state: check length
Date: Thu, 23 May 2019 08:57:12 +0200 [thread overview]
Message-ID: <20190523065712.isc4cdwsnbqvmtf7@pengutronix.de> (raw)
In-Reply-To: <1558449853-28519-1-git-send-email-j.remmet@phytec.de>
On Tue, May 21, 2019 at 04:44:13PM +0200, Jan Remmet wrote:
> if written_length is read from a partial written bucket it may be to
> big and xmalloc will panic barebox.
>
> Check if the value is sane.
>
> Signed-off-by: Jan Remmet <j.remmet@phytec.de>
> ---
> common/state/backend_bucket_direct.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c
> index 95ddb9310685..fc633eea8dec 100644
> --- a/common/state/backend_bucket_direct.c
> +++ b/common/state/backend_bucket_direct.c
> @@ -67,6 +67,10 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
> }
> if (meta.magic == direct_magic) {
> read_len = meta.written_length;
> + if (read_len < 0 || read_len > direct->max_size) {
written_length in struct state_backend_storage_bucket_direct_meta is
unsigned and so should be read_len. Then you can skip the read_len < 0
check.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2019-05-23 6:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-21 14:44 Jan Remmet
2019-05-23 6:57 ` Sascha Hauer [this message]
2019-05-23 7:49 ` [PATCH v2] " Jan Remmet
2019-05-23 8:00 ` 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=20190523065712.isc4cdwsnbqvmtf7@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=j.remmet@phytec.de \
/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