diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2015-04-22 19:07:19 +0000 |
---|---|---|
committer | Rafał Miłecki <zajec5@gmail.com> | 2015-04-22 19:07:19 +0000 |
commit | 3931288caa4da33d45571d9101010e95d8739738 (patch) | |
tree | ff2d136c51a9c82c267316b57a2a9450156dc2ba /package/utils | |
parent | d94fb398f682374407b926bf8a85afade3136788 (diff) | |
download | upstream-3931288caa4da33d45571d9101010e95d8739738.tar.gz upstream-3931288caa4da33d45571d9101010e95d8739738.tar.bz2 upstream-3931288caa4da33d45571d9101010e95d8739738.zip |
nvram: refuse to open NVRAM for writing if it's too big to be handled
Otherwise writing anything will result in loosing data.
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
SVN-Revision: 45565
Diffstat (limited to 'package/utils')
-rw-r--r-- | package/utils/nvram/src/nvram.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/package/utils/nvram/src/nvram.c b/package/utils/nvram/src/nvram.c index f2c79ff7ba..0e1c726837 100644 --- a/package/utils/nvram/src/nvram.c +++ b/package/utils/nvram/src/nvram.c @@ -389,8 +389,8 @@ nvram_handle_t * nvram_open(const char *file, int rdonly) header = nvram_header(h); - if( header->magic == NVRAM_MAGIC ) - { + if (header->magic == NVRAM_MAGIC && + (rdonly || header->len < NVRAM_SPACE)) { _nvram_rehash(h); free(mtd); return h; |