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@xxxxxxxxx> > --- > 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@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox