From: Rafał Miłecki Date: Wed, 22 Apr 2015 19:07:19 +0000 (+0000) Subject: nvram: refuse to open NVRAM for writing if it's too big to be handled X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3931288caa4da33d45571d9101010e95d8739738;p=librecmc%2Flibrecmc.git 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 SVN-Revision: 45565 --- 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;