From dcfd984d8e09db9d5a7b4d121d914442966c254f Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 25 Jan 2020 14:39:08 +0100 Subject: mtd-utils: Fix potentially unterminated strings This commit fixes some uses of strncpy that could leave the destination buffer unterminated. Signed-off-by: David Oberhollenzer --- lib/libubi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/libubi.c b/lib/libubi.c index afe3648..baaca2f 100644 --- a/lib/libubi.c +++ b/lib/libubi.c @@ -1008,7 +1008,8 @@ int ubi_mkvol(libubi_t desc, const char *node, struct ubi_mkvol_request *req) if (n > UBI_MAX_VOLUME_NAME) return -1; - strncpy(r.name, req->name, UBI_MAX_VOLUME_NAME + 1); + strncpy(r.name, req->name, UBI_MAX_VOLUME_NAME); + r.name[UBI_MAX_VOLUME_NAME] = '\0'; r.name_len = n; fd = open(node, O_RDONLY); -- cgit v1.2.3