Skip to content

Commit

Permalink
UBI: do not let to read too much
Browse files Browse the repository at this point in the history
In case of static volumes it is prohibited to read more data
then available.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
  • Loading branch information
Artem Bityutskiy authored and Artem Bityutskiy committed Jul 18, 2007
1 parent 78d87c9 commit 4ab60a0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/mtd/ubi/kapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,14 @@ int ubi_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset,
offset + len > vol->usable_leb_size)
return -EINVAL;

if (vol->vol_type == UBI_STATIC_VOLUME && lnum == vol->used_ebs - 1 &&
offset + len > vol->last_eb_bytes)
return -EINVAL;
if (vol->vol_type == UBI_STATIC_VOLUME) {
if (vol->used_ebs == 0)
/* Empty static UBI volume */
return 0;
if (lnum == vol->used_ebs - 1 &&
offset + len > vol->last_eb_bytes)
return -EINVAL;
}

if (vol->upd_marker)
return -EBADF;
Expand Down

0 comments on commit 4ab60a0

Please sign in to comment.