From d71f5ad24663624a17d335462908ae5a8f69bcf7 Mon Sep 17 00:00:00 2001 From: Iker Pedrosa Date: Mon, 29 Jul 2024 12:57:18 +0200 Subject: [PATCH] core: fix chip-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/1d7cf79edf75ef77baa56091852be90e2359e572.1722250385.git.ikerpedrosam@gmail.com Signed-off-by: Bartosz Golaszewski --- lib/chip-info.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/chip-info.c b/lib/chip-info.c index 87fd9e7..478cd62 100644 --- a/lib/chip-info.c +++ b/lib/chip-info.c @@ -10,8 +10,8 @@ struct gpiod_chip_info { size_t num_lines; - char name[32]; - char label[32]; + char name[GPIO_MAX_NAME_SIZE+1]; + char label[GPIO_MAX_NAME_SIZE+1]; }; GPIOD_API void gpiod_chip_info_free(struct gpiod_chip_info *info) -- 2.30.2