From c978f2fe4c7f29eba1dacb3065572030a7a0578c Mon Sep 17 00:00:00 2001 From: dongjiuzhu1 Date: Wed, 8 May 2024 19:49:11 +0800 Subject: [PATCH] drivers/mtd/bch: fix size_t overflow when offset > 4GB Signed-off-by: dongjiuzhu1 --- drivers/bch/bchlib_read.c | 2 +- drivers/bch/bchlib_write.c | 2 +- drivers/mtd/filemtd.c | 2 +- include/nuttx/drivers/drivers.h | 4 ++-- include/nuttx/mtd/mtd.h | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/bch/bchlib_read.c b/drivers/bch/bchlib_read.c index 69b8c6c70c..86ed93fe28 100644 --- a/drivers/bch/bchlib_read.c +++ b/drivers/bch/bchlib_read.c @@ -64,7 +64,7 @@ * ****************************************************************************/ -ssize_t bchlib_read(FAR void *handle, FAR char *buffer, size_t offset, +ssize_t bchlib_read(FAR void *handle, FAR char *buffer, off_t offset, size_t len) { FAR struct bchlib_s *bch = (FAR struct bchlib_s *)handle; diff --git a/drivers/bch/bchlib_write.c b/drivers/bch/bchlib_write.c index c63715c67c..9a08bf0b4f 100644 --- a/drivers/bch/bchlib_write.c +++ b/drivers/bch/bchlib_write.c @@ -50,7 +50,7 @@ * ****************************************************************************/ -ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, +ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, off_t offset, size_t len) { FAR struct bchlib_s *bch = (FAR struct bchlib_s *)handle; diff --git a/drivers/mtd/filemtd.c b/drivers/mtd/filemtd.c index 5fd6d614cf..7a87496c59 100644 --- a/drivers/mtd/filemtd.c +++ b/drivers/mtd/filemtd.c @@ -725,7 +725,7 @@ static int mtd_loop_ioctl(FAR struct file *filep, int cmd, * ****************************************************************************/ -FAR struct mtd_dev_s *filemtd_initialize(FAR const char *path, size_t offset, +FAR struct mtd_dev_s *filemtd_initialize(FAR const char *path, off_t offset, int16_t sectsize, int32_t erasesize) { FAR struct file_dev_s *priv; diff --git a/include/nuttx/drivers/drivers.h b/include/nuttx/drivers/drivers.h index b8eb6f4cb2..3a44dc5b39 100644 --- a/include/nuttx/drivers/drivers.h +++ b/include/nuttx/drivers/drivers.h @@ -231,7 +231,7 @@ int bchlib_teardown(FAR void *handle); * ****************************************************************************/ -ssize_t bchlib_read(FAR void *handle, FAR char *buffer, size_t offset, +ssize_t bchlib_read(FAR void *handle, FAR char *buffer, off_t offset, size_t len); /**************************************************************************** @@ -243,7 +243,7 @@ ssize_t bchlib_read(FAR void *handle, FAR char *buffer, size_t offset, * ****************************************************************************/ -ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, +ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, off_t offset, size_t len); /**************************************************************************** diff --git a/include/nuttx/mtd/mtd.h b/include/nuttx/mtd/mtd.h index 5b394ac326..59e86a5d4b 100644 --- a/include/nuttx/mtd/mtd.h +++ b/include/nuttx/mtd/mtd.h @@ -657,7 +657,7 @@ FAR struct mtd_dev_s *w25qxxxjv_initialize(FAR struct qspi_dev_s *qspi, * ****************************************************************************/ -FAR struct mtd_dev_s *filemtd_initialize(FAR const char *path, size_t offset, +FAR struct mtd_dev_s *filemtd_initialize(FAR const char *path, off_t offset, int16_t sectsize, int32_t erasesize);