nvram: fix "Segmentation fault" caused by setting memory out of buffer
authorrmilecki <rmilecki@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Wed, 8 Jul 2015 04:55:04 +0000 (04:55 +0000)
committerrmilecki <rmilecki@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Wed, 8 Jul 2015 04:55:04 +0000 (04:55 +0000)
commitc1e9836221fa715fb5e50e0910d88dc2934260d9
tree825bdaf90073ed354b7621124144877647b610b0
parentdbde9080c9bb388d32078853c8b757631676613a
nvram: fix "Segmentation fault" caused by setting memory out of buffer

Some MTD partitions with NVRAM have content starting in the middle. In
such case offset is set and nvram_header returns pointer to the middle.
It means we have to respect offset when calculating remaining space.

By the way use real MTD partition size (nvram_part_size variable) as we
may want to bump NVRAM_SPACE in the (very near) future.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Backport of r46251

git-svn-id: svn://svn.openwrt.org/openwrt/branches/chaos_calmer@46258 3c298f89-4303-0410-b956-a3cf2f4a3e73
package/utils/nvram/src/nvram.c