From 5ce22392e8e12555d41262554f52ea2625e3eadb Mon Sep 17 00:00:00 2001 From: Michal Bloch Date: Tue, 29 Jun 2021 20:34:57 +0200 Subject: [PATCH] Linting: buffer size safety Make sure the buffer's actual size is used. This safeguards against somebody changing the size of the buffer but forgetting to change the value that gets passed as its size to other functions. Change-Id: I12c78acf56daf55a785e9c994ca70ed34a38a1de --- src/peripheral_gpio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/peripheral_gpio.c b/src/peripheral_gpio.c index fa9c870..a7c51d4 100644 --- a/src/peripheral_gpio.c +++ b/src/peripheral_gpio.c @@ -184,7 +184,7 @@ static int peripheral_gpio_set_initial_direction_into_handle(peripheral_gpio_h g char gpio_buf[GPIO_BUFFER_MAX] = {0, }; - int ret = read(gpio->fd_direction, &gpio_buf, GPIO_BUFFER_MAX); + int ret = read(gpio->fd_direction, &gpio_buf, sizeof gpio_buf); CHECK_ERROR(ret <= 0); for (size_t index = 0; index < ARRAY_SIZE(types); index++) { @@ -219,7 +219,7 @@ static int peripheral_gpio_set_initial_edge_into_handle(peripheral_gpio_h gpio) char gpio_buf[GPIO_BUFFER_MAX] = {0, }; - int ret = read(gpio->fd_edge, &gpio_buf, GPIO_BUFFER_MAX); + int ret = read(gpio->fd_edge, &gpio_buf, sizeof gpio_buf); CHECK_ERROR(ret <= 0); for (size_t index = 0; index < ARRAY_SIZE(types); index++) { -- 2.7.4