From 2be4975f18f6e49b53ae683a30b11e435a5515dd Mon Sep 17 00:00:00 2001 From: Orestis Date: Sun, 7 Oct 2018 21:26:37 +0300 Subject: [PATCH] resolve_tilde: strncpy + strlen is pointless (#3436) strlen already assumes that the string is NULL-terminated. Like in https://github.com/i3/i3status/pull/312 but for whatever reason gcc didn't warn about this here. --- libi3/resolve_tilde.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libi3/resolve_tilde.c b/libi3/resolve_tilde.c index 51d642db..6dbf132f 100644 --- a/libi3/resolve_tilde.c +++ b/libi3/resolve_tilde.c @@ -35,9 +35,10 @@ char *resolve_tilde(const char *path) { } else { head = globbuf.gl_pathv[0]; result = scalloc(strlen(head) + (tail ? strlen(tail) : 0) + 1, 1); - strncpy(result, head, strlen(head)); - if (tail) - strncat(result, tail, strlen(tail)); + strcpy(result, head); + if (tail) { + strcat(result, tail); + } } globfree(&globbuf); -- 2.39.2