aboutsummaryrefslogtreecommitdiffstats
path: root/package/utils/nvram
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2015-04-22 19:07:19 +0000
committerRafał Miłecki <zajec5@gmail.com>2015-04-22 19:07:19 +0000
commit3931288caa4da33d45571d9101010e95d8739738 (patch)
treeff2d136c51a9c82c267316b57a2a9450156dc2ba /package/utils/nvram
parentd94fb398f682374407b926bf8a85afade3136788 (diff)
downloadupstream-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/nvram')
-rw-r--r--package/utils/nvram/src/nvram.c4
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;