Skip to contentSkip to conversation

drivers/mtd/ubispl/ubispl.c: limit copy size

PATCH RESEND In review Benedikt Spranger 2 participants 2 messages Sep 17, 2025 – Oct 9, 2025 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 drivers/mtd/ubispl/ubispl.c: limit copy size

The fastmap VID header is embedded in struct ubi_scan_info. During fastmap scan, the header is copied into struct ubi_scan_info, if valid. The former code mixed up the amount of copied bytes and copied more bytes than nessesary. This had no side effect, since the affected struct members are uninitialized at that point and overwritten later.

Limit the copied bytes to the VID header size.

---
 drivers/mtd/ubispl/ubispl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/ubispl/ubispl.c +1 -1
index 9face5fae15..0143caa051d 100644
@@ -779,7 +779,7 @@ static int ubi_scan_fastmap(struct ubi_scan_info *ubi,
 		 * that already so we merily copy it over.
 		 */
 		if (pnum == fm_anchor)
-			memcpy(vh, ubi->blockinfo + pnum, sizeof(*fm));
+			memcpy(vh, ubi->blockinfo + pnum, sizeof(*vh));
 
 		if (i == 0) {
 			if (be32_to_cpu(vh->vol_id) != UBI_FM_SB_VOLUME_ID) {
Signature · 1 line
2.51.0
#1 lore raw

Hello Benedikt,

Quoted 6 lines · Benedikt Spranger

The fastmap VID header is embedded in struct ubi_scan_info. During fastmap scan, the header is copied into struct ubi_scan_info, if valid. The former code mixed up the amount of copied bytes and copied more bytes than nessesary. This had no side effect, since the affected struct members are uninitialized at that point and overwritten later.

Quoted 7 lines

Limit the copied bytes to the VID header size.

---
  drivers/mtd/ubispl/ubispl.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-ubi

Thanks!

bye,
Heiko

Signature · 5 lines
Nabla Software Engineering
HRB 40522 Augsburg
Phone: +49 821 45592596
E-Mail: [email protected]
Geschäftsführer : Stefano Babic