]> git.ipfire.org Git - thirdparty/openwrt.git/commit
mtd: check return values of lseek() and write() in mtd_write_buffer() 23552/head
authorAnna Kiri <bredcorn@gmail.com>
Mon, 8 Jun 2026 09:05:55 +0000 (11:05 +0200)
committerJonas Jelonek <jelonek.jonas@gmail.com>
Mon, 8 Jun 2026 14:17:02 +0000 (16:17 +0200)
commit2f809f9cff578141def1fd00baf22384afd75c21
tree0a0eeb49852b8e887af253a179773485f8933862
parente122d4957782d170a78a6872559e9ff8cde469f9
mtd: check return values of lseek() and write() in mtd_write_buffer()

Two ignored return values in mtd_write_buffer() caused silent failures:

- lseek() return value was ignored. A failed seek (e.g. EBADF, ESPIPE)
  followed by write() would silently write at the wrong offset.
- write() return value was ignored, silently discarding write errors.
  This could lead to data corruption on the MTD device without any
  indication.

Check both return values, report errors to stderr and return -1 on
failure.

Signed-off-by: Anna Kiri <bredcorn@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/23552
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
package/system/mtd/src/mtd.c