X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/f0fca04e4e136c4a487a922e8fb09acf46aeafa0..7a6421fa764dd0f609e2a5024ec8b3bc577575a1:/util.c diff --git a/util.c b/util.c index f74228ef..9b28cb03 100644 --- a/util.c +++ b/util.c @@ -446,3 +446,12 @@ void kill_all(int sig) } } +/* like strncpy but does not 0 fill the buffer and always null + terminates (thus it can use maxlen+1 space in d) */ +void strlcpy(char *d, char *s, int maxlen) +{ + int len = strlen(s); + if (len > maxlen) len = maxlen; + memcpy(d, s, len); + d[len] = 0; +}