Edward O'Callaghan submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Anastasia Klimchuk: Looks good to me, approved
tests/linux_spi: Validate params file path and flags

Add path and flags validation for '/dev/null' to open operation.

BUG=b:217629892,b:215255210
TEST=`ninja test`.

Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Co-Author: Daniel Campello <campello@chromium.org>
Signed-off-by: Daniel Campello <campello@chromium.org>
Change-Id: If5d24c65f291c53a35509fea5d2f5b3fdb51c306
Reviewed-on: https://review.coreboot.org/c/flashrom/+/62319
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
---
M tests/lifecycle.c
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/tests/lifecycle.c b/tests/lifecycle.c
index 5566b3b..1a8f218 100644
--- a/tests/lifecycle.c
+++ b/tests/lifecycle.c
@@ -355,9 +355,15 @@
* Specifically, it is reading the buffer size from sysfs.
*/
#if CONFIG_LINUX_SPI == 1
+ static struct io_mock_fallback_open_state linux_spi_fallback_open_state = {
+ .noc = 0,
+ .paths = { "/dev/null", NULL },
+ .flags = { O_RDWR },
+ };
const struct io_mock linux_spi_io = {
.fgets = linux_spi_fgets,
.ioctl = linux_spi_ioctl,
+ .fallback_open_state = &linux_spi_fallback_open_state,
};

io_mock_register(&linux_spi_io);

To view, visit change 62319. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: If5d24c65f291c53a35509fea5d2f5b3fdb51c306
Gerrit-Change-Number: 62319
Gerrit-PatchSet: 15
Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-Reviewer: Daniel Campello <campello@chromium.org>
Gerrit-Reviewer: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Sam McNally <sammc@google.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter@mailbox.org>
Gerrit-MessageType: merged