From f242b6973dadee0d6d539b6a8ab0f25caf70e75a Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Tue, 6 Sep 2022 10:18:42 +0900 Subject: [PATCH] clients: Silence wstringop-truncation warning Change-Id: Ia90870b6b2b21832f7f440cd141c368a314a86b3 --- clients/simple-shm-shell.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/clients/simple-shm-shell.c b/clients/simple-shm-shell.c index e0bdcb4..cbcdf97 100644 --- a/clients/simple-shm-shell.c +++ b/clients/simple-shm-shell.c @@ -100,8 +100,14 @@ _create_anonymous_file (off_t size) return -1; } + if (strlen(path) + strlen(template) > (PATH_MAX - 1)) { + errno = ENAMETOOLONG; + return -1; + } + strncpy(name, path, PATH_MAX); - strncat(name, template, PATH_MAX); + name[PATH_MAX - 1] = '\0'; + strncat(name, template, strlen(template)); fd = mkstemp(name); if (fd < 0) -- 2.7.4