X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/bf4e725d5d3c0a06c9a8d74cb9b1c183e161f148..c127e8aaec2b0ea408a3cd3a36fd910520249332:/syscall.c diff --git a/syscall.c b/syscall.c index b4b581b9..b198dbf4 100644 --- a/syscall.c +++ b/syscall.c @@ -113,15 +113,19 @@ int do_rename(char *fname1, char *fname2) void trim_trailing_slashes(char *name) { - char *p; + int l; /* Some BSD systems cannot make a directory if the name * contains a trailing slash. * */ - if (!*name) - return; /* empty string */ - p = strchr(name, '\0') - 1; - while (p == '/') { - p-- = '\0'; + + /* Don't change empty string; and also we can't improve on + * "/" */ + + l = strlen(name); + while (l > 1) { + if (name[--l] != '/') + break; + name[l] = '\0'; } }