Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
resolve_tilde: strncpy + strlen is pointless (#3436)
strlen already assumes that the string is NULL-terminated.

Like in i3/i3status#312 but for whatever reason
gcc didn't warn about this here.
  • Loading branch information
orestisfl authored and stapelberg committed Oct 7, 2018
1 parent 18dbfe6 commit 2be4975
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions libi3/resolve_tilde.c
Expand Up @@ -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);

Expand Down

0 comments on commit 2be4975

Please sign in to comment.