aboutsummaryrefslogtreecommitdiffstats
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
commit41b471d235b87c7d3bd1e7e91063b3b8fc6dd52e (patch)
treeac9041994b160edbbee6e38e210fc297a33942b1
parent41ba634460d69ea879b66c18255bc1d67769196e (diff)
downloadupstream-41b471d235b87c7d3bd1e7e91063b3b8fc6dd52e.tar.gz
upstream-41b471d235b87c7d3bd1e7e91063b3b8fc6dd52e.tar.bz2
upstream-41b471d235b87c7d3bd1e7e91063b3b8fc6dd52e.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> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@45565 3c298f89-4303-0410-b956-a3cf2f4a3e73
-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;