From ee5c7ebf13c1fd1cc573944d6dac09d68e4544c4 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Thu, 21 May 2026 14:47:03 +0200 Subject: [PATCH] Verify smartignore range --- cmdline/device.c | 6 ++++-- cmdline/state.c | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cmdline/device.c b/cmdline/device.c index dfc66380..2ee0dc74 100644 --- a/cmdline/device.c +++ b/cmdline/device.c @@ -531,8 +531,10 @@ static void state_smart_ignore(struct snapraid_state* state, devinfo_t* devinfo) { /* clear attributes to ignore */ for (int i = 0; i < SMART_IGNORE_MAX; ++i) { - devinfo->smart[state->smartignore[i]].raw = SMART_UNASSIGNED; - devinfo->smart[devinfo->smartignore[i]].raw = SMART_UNASSIGNED; + if (state->smartignore[i] < 256) + devinfo->smart[state->smartignore[i]].raw = SMART_UNASSIGNED; + if (devinfo->smartignore[i] < 256) + devinfo->smart[devinfo->smartignore[i]].raw = SMART_UNASSIGNED; } } diff --git a/cmdline/state.c b/cmdline/state.c index 25ce7089..a1ca4e41 100644 --- a/cmdline/state.c +++ b/cmdline/state.c @@ -1267,7 +1267,14 @@ void state_config(struct snapraid_state* state, const char* path, const char* co if (!e || *e) { /* LCOV_EXCL_START */ - log_fatal(EUSER, "Invalid 'smartignore' specification in '%s' at line %u\n", path, line); + log_fatal(EUSER, "Invalid 'smartignore' specification in '%s' at line %u. It should be a number.\n", path, line); + exit(EXIT_FAILURE); + /* LCOV_EXCL_STOP */ + } + + if (smart[si] < 1 || smart[si] >= 256) { + /* LCOV_EXCL_START */ + log_fatal(EUSER, "Invalid 'smartignore' specification in '%s' at line %u. It should be between 1 and 255.\n", path, line); exit(EXIT_FAILURE); /* LCOV_EXCL_STOP */ }