-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix buffer overrun in lfs_cache_zero
lfs_cache_zero assumes that the buffer which it is passed is prog_size in length. There are two cases where this is false: 1. In lfs_file_opencfg, when the file is opened readonly file->cache.buffer is malloc'd as read_size 2. In lfs_init, lfs->rcache is always malloc'd as read_size, passed to lfs_cache_zero. In both cases, the buffer in question is passed to lfs_cache_zero later in the same function. To address this, add a cache_size argument to lfs_cache_zero, which is set to either read_size or prog_size as appropriate based on the caller's knowledge of the buffer that it is passing in. The "pcache" argument to lfs_cache_zero is renamed to simply "cache" to make it clear that this pointer is not necessarily to a program cache.
- Loading branch information
Kyle Kearney
committed
Oct 3, 2019
1 parent
c385e14
commit 84f54b6
Showing
1 changed file
with
13 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters