diff mbox series

[libgpiod,v2,3/4] lib: chip-info strings termination

Message ID 1d7cf79edf75ef77baa56091852be90e2359e572.1722250385.git.ikerpedrosam@gmail.com
State New
Headers show
Series Fix issues detected by static analyzer | expand

Commit Message

Iker Pedrosa July 29, 2024, 10:57 a.m. UTC
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>
---
 lib/chip-info.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

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)