core: fix chip-info strings termination
authorIker Pedrosa <ikerpedrosam@gmail.com>
Mon, 29 Jul 2024 10:57:18 +0000 (12:57 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Wed, 31 Jul 2024 08:57:59 +0000 (10:57 +0200)
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 <ikerpedrosam@gmail.com>
Link: https://lore.kernel.org/r/1d7cf79edf75ef77baa56091852be90e2359e572.1722250385.git.ikerpedrosam@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
lib/chip-info.c

index 87fd9e7c7e3b82c0af9a82276a466e188a708855..478cd62a0c45cad86f3b0cfebf2de969f4d8818e 100644 (file)
@@ -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)