From: Daniel Wagner <[email protected]>

strncpy does not null terminate the string if basepath is longer
than the max size of the buffer. Let's stop at max - 1 and have
proper terminated string.

Reported by coverty.
---
 src/timezone.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/timezone.c b/src/timezone.c
index 98908ad..e346b11 100644
--- a/src/timezone.c
+++ b/src/timezone.c
@@ -161,7 +161,7 @@ static char *find_origin(void *src_map, struct stat *src_st,
        int ret;
 
        if (!subpath)
-               strncpy(pathname, basepath, sizeof(pathname));
+               strncpy(pathname, basepath, sizeof(pathname) - 1);
        else
                snprintf(pathname, sizeof(pathname),
                                        "%s/%s", basepath, subpath);
-- 
1.8.4.474.g128a96c

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to