From 70eb11c61b46cc474df1eb188c7b35fc9eb2e275 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Tue, 7 Sep 2021 19:15:36 +0300 Subject: [PATCH] NVRAM write wraparound fix. --- flashrom.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/flashrom.cpp b/flashrom.cpp index 62defd7b..75138a72 100644 --- a/flashrom.cpp +++ b/flashrom.cpp @@ -333,8 +333,18 @@ static void bitbang_i2c_enter_stop(bitbang_i2c_interface *i2c) #if EEPROM_LOG write_log(_T("I2C STOP\n")); #endif - if (i2c->write_offset >= 0) - nvram_write(i2c, i2c->write_offset, 16); + if (i2c->write_offset >= 0) { + int len = i2c->size - i2c->write_offset; + if (len > 16) { + len = 16; + } + if (len > 0) { + nvram_write(i2c, i2c->write_offset, len); + } + if (len < 16) { + nvram_write(i2c, 0, 16 - len); + } + } i2c->write_offset = -1; i2c->current_addr = -1; i2c->state = STOPPED; -- 2.47.3