core: sanitize arguments in gpiod_line_config_set_output_values()
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 13 Mar 2023 15:28:51 +0000 (16:28 +0100)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 13 Mar 2023 15:49:54 +0000 (16:49 +0100)
Add an assert() for the line config structure and check the rest of the
arguments for invalid values.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
lib/line-config.c

index 2b2c0ec67b48d33ea0381d4170146d95525f7921..2749a2a00b0ef44bf617b9994ff9e9d01f5f882e 100644 (file)
@@ -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;
        }