Re: [PATCH v2] ubi: Fix failure attaching when vid_hdr offset equals to (sub)page size

From: Richard Weinberger
Date: Sat Mar 04 2023 - 12:11:17 EST


----- Ursprüngliche Mail -----
> Von: "chengzhihao1" <chengzhihao1@xxxxxxxxxx>
> + /*
> + * Memory allocation for VID header is ubi->vid_hdr_alsize
> + * which is described in comments in io.c.
> + * Make sure VID header shift + UBI_VID_HDR_SIZE not exceeds
> + * ubi->vid_hdr_alsize, so that all vid header operations
> + * won't access memory out of bounds.
> + */
> + if ((ubi->vid_hdr_shift + UBI_VID_HDR_SIZE) > ubi->vid_hdr_alsize) {
> + ubi_err(ubi, "Invalid VID header offset %d, VID header shift(%d)"
> + " + VID header size(%d) > VID header aligned size(%d).",
> + ubi->vid_hdr_offset, ubi->vid_hdr_shift,
> + (int)UBI_VID_HDR_SIZE, ubi->vid_hdr_alsize);

Hmm, why are you casting to int instead of using %zu as format string?

Thanks,
//richard