From 3931288caa4da33d45571d9101010e95d8739738 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Wed, 22 Apr 2015 19:07:19 +0000 Subject: [PATCH] nvram: refuse to open NVRAM for writing if it's too big to be handled MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Otherwise writing anything will result in loosing data. Signed-off-by: Rafał Miłecki SVN-Revision: 45565 --- package/utils/nvram/src/nvram.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/utils/nvram/src/nvram.c b/package/utils/nvram/src/nvram.c index f2c79ff7ba7..0e1c7268375 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; -- 2.30.2