sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

commit fdb9084da94067627941f4f7ee414c447866006a
parent 5c76e79f41250d505bca09d36a5518bf66c51749
Author: Michael Forney <mforney@mforney.org>
Date:   Sat, 20 Jun 2020 18:21:35 -0700

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.

Diffstat:
Mlibutil/recurse.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libutil/recurse.c b/libutil/recurse.c @@ -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))) {