From f55da6941c76cf213fb1f24a8d13ce98191db943 Mon Sep 17 00:00:00 2001 From: batt Date: Wed, 2 Feb 2011 21:02:54 +0000 Subject: [PATCH] Correctly handle reading/writing after EOF. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4674 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/io/kfile_block.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bertos/io/kfile_block.c b/bertos/io/kfile_block.c index a4278fb0..e3bcdd39 100644 --- a/bertos/io/kfile_block.c +++ b/bertos/io/kfile_block.c @@ -62,6 +62,8 @@ INLINE KFileBlock * KFILEBLOCK_CAST(KFile *fd) while (size) \ { \ block_idx_t id = (fd)->seek_pos / fb->blk->blk_size; \ + if (id >= fb->blk->blk_cnt) \ + break; \ size_t offset = (fd)->seek_pos % fb->blk->blk_size; \ size_t count = MIN(size, (size_t)(fb->blk->blk_size - offset)); \ size_t ret_len = kblock_##dir(fb->blk, id, buf, offset, count); \ -- 2.25.1