This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit 9eda75b7301cd4f72a283e58804334f13d7c41f7 Author: xuxingliang <[email protected]> AuthorDate: Tue Dec 10 15:24:36 2024 +0800 system/coredump: fix core file size mismatch Write exactly the same data size to core file. Signed-off-by: xuxingliang <[email protected]> --- system/coredump/coredump.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/system/coredump/coredump.c b/system/coredump/coredump.c index e4e1c5189..e35d7a5a8 100644 --- a/system/coredump/coredump.c +++ b/system/coredump/coredump.c @@ -293,7 +293,13 @@ static void coredump_restore(FAR char *savepath, size_t maxfile) lseek(blkfd, 0, SEEK_SET); while (offset < info.size) { - readsize = read(blkfd, swap, CONFIG_SYSTEM_COREDUMP_SWAPBUFFER_SIZE); + readsize = info.size - offset; + if (readsize > CONFIG_SYSTEM_COREDUMP_SWAPBUFFER_SIZE) + { + readsize = CONFIG_SYSTEM_COREDUMP_SWAPBUFFER_SIZE; + } + + readsize = read(blkfd, swap, readsize); if (readsize < 0) { printf("Read %s fail\n", CONFIG_SYSTEM_COREDUMP_DEVPATH);
