From: Orestis Date: Sun, 7 Oct 2018 18:26:37 +0000 (+0300) Subject: resolve_tilde: strncpy + strlen is pointless (#3436) X-Git-Tag: 4.16~23 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2be4975f18f6e49b53ae683a30b11e435a5515dd;p=i3%2Fi3 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. --- 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);