From: Iker Pedrosa Date: Mon, 29 Jul 2024 10:57:17 +0000 (+0200) Subject: core: fix line-info strings termination X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=5533f277aa28b36f8ed4bbfac8e22e011ed68858;p=qemu-gpiodev%2Flibgpiod.git core: fix line-info strings termination strncpy() truncates the destination buffer if it isn't large enough to hold the copy. Thus, let's increase the size of the destination strings to add the NULL character at the end. Signed-off-by: Iker Pedrosa Link: https://lore.kernel.org/r/84db7bbe2c84b2d880052a05f8b1cc123d60c2dc.1722250385.git.ikerpedrosam@gmail.com Signed-off-by: Bartosz Golaszewski --- diff --git a/lib/line-info.c b/lib/line-info.c index 9f53b04..a7c6241 100644 --- a/lib/line-info.c +++ b/lib/line-info.c @@ -10,9 +10,9 @@ struct gpiod_line_info { unsigned int offset; - char name[GPIO_MAX_NAME_SIZE]; + char name[GPIO_MAX_NAME_SIZE+1]; bool used; - char consumer[GPIO_MAX_NAME_SIZE]; + char consumer[GPIO_MAX_NAME_SIZE+1]; enum gpiod_line_direction direction; bool active_low; enum gpiod_line_bias bias;