From 49e907e5f60cb7059d72c65335ceef75c5e4fded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Mon, 29 Jun 2020 17:28:36 +0200 Subject: [PATCH] libc: remove trailing slash in lstat and stat Fixes #3814. --- repos/libports/src/lib/libc/file_operations.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/repos/libports/src/lib/libc/file_operations.cc b/repos/libports/src/lib/libc/file_operations.cc index 573170df6..cd181ef90 100644 --- a/repos/libports/src/lib/libc/file_operations.cc +++ b/repos/libports/src/lib/libc/file_operations.cc @@ -374,6 +374,7 @@ extern "C" int lstat(const char *path, struct stat *buf) try { Absolute_path resolved_path; resolve_symlinks_except_last_element(path, resolved_path); + resolved_path.remove_trailing('/'); FNAME_FUNC_WRAPPER(stat, resolved_path.base(), buf); } catch (Symlink_resolve_error) { return -1; @@ -649,6 +650,7 @@ extern "C" int stat(const char *path, struct stat *buf) try { Absolute_path resolved_path; resolve_symlinks(path, resolved_path); + resolved_path.remove_trailing('/'); FNAME_FUNC_WRAPPER(stat, resolved_path.base(), buf); } catch(Symlink_resolve_error) { return -1;