--- ls.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ls.c b/ls.c index 72d7434..4b51d17 100644 --- a/ls.c +++ b/ls.c _AT_@ -276,8 +276,12 @@ lsdir(const char *path, const struct entry *dir) output(&ents[i]); if (Rflag) { - if (snprintf(prefix, PATH_MAX, "%s%s/", path, dir->name) >= - PATH_MAX) + i = strlen(dir->name); + if (i && dir->name[i - 1] == '/') + i = snprintf(prefix, PATH_MAX, "%s%s", path, dir->name); + else + i = snprintf(prefix, PATH_MAX, "%s%s/", path, dir->name); + if (i >= PATH_MAX) eprintf("path too long: %s%s\n", path, dir->name); for (i = 0; i < n; i++) { -- 2.1.4Received on Wed Feb 17 2016 - 21:37:59 CET
This archive was generated by hypermail 2.3.0 : Wed Feb 17 2016 - 21:48:11 CET