From: batt Date: Wed, 2 Feb 2011 21:02:54 +0000 (+0000) Subject: Correctly handle reading/writing after EOF. X-Git-Tag: 2.7.0~292 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=f55da6941c76cf213fb1f24a8d13ce98191db943;p=bertos.git Correctly handle reading/writing after EOF. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4674 38d2e660-2303-0410-9eaa-f027e97ec537 --- 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); \