From 3c55c6f3e0c94333acf6f3da1e96ef17fd430887 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Mon, 13 Mar 2023 16:28:51 +0100 Subject: [PATCH] core: sanitize arguments in gpiod_line_config_set_output_values() Add an assert() for the line config structure and check the rest of the arguments for invalid values. Signed-off-by: Bartosz Golaszewski --- lib/line-config.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/line-config.c b/lib/line-config.c index 2b2c0ec..2749a2a 100644 --- a/lib/line-config.c +++ b/lib/line-config.c @@ -184,7 +184,9 @@ gpiod_line_config_set_output_values(struct gpiod_line_config *config, size_t i; int ret; - if (num_values > LINES_MAX) { + assert(config); + + if (!num_values || num_values > LINES_MAX || !values) { errno = EINVAL; return -1; } -- 2.30.2