libutil/recurse: Simplify adding trailing slash

We know that r->pathlen < sizeof(r->path) since r->path is
nul-terminated, so we can safely add a '/' here. If there is no
space left over for the rest of the path and nul-terminator, this
will be caught by the subsequent estrlcpy.
This commit is contained in:
Michael Forney 2020-06-20 18:21:35 -07:00
parent 5c76e79f41
commit fdb9084da9
1 changed files with 1 additions and 1 deletions

View File

@ -70,7 +70,7 @@ recurse(int dirfd, const char *name, void *data, struct recursor *r)
return;
}
if (r->path[pathlen - 1] != '/')
pathlen += estrlcpy(r->path + pathlen, "/", sizeof(r->path) - pathlen);
r->path[pathlen++] = '/';
if (r->follow == 'H')
flags |= AT_SYMLINK_NOFOLLOW;
while ((d = readdir(dp))) {