From 5fbd3e5c6509e87d2aa00d3f8a25098a0ab1188b Mon Sep 17 00:00:00 2001 From: LoveSy Date: Tue, 19 Sep 2023 02:21:19 +0800 Subject: [PATCH] Fix buf len update of read_link to Utf8CStrBuf --- native/src/base/files.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/native/src/base/files.rs b/native/src/base/files.rs index 7b1f44fda..2ad3a7cdb 100644 --- a/native/src/base/files.rs +++ b/native/src/base/files.rs @@ -411,8 +411,12 @@ impl FsPath { pub fn read_link(&self, buf: &mut dyn Utf8CStrBuf) -> io::Result<()> { buf.clear(); - unsafe { readlink_unsafe(self.as_ptr(), buf.as_mut_ptr().cast(), buf.capacity()) } - .as_os_err() + unsafe { + let c = readlink_unsafe(self.as_ptr(), buf.as_mut_ptr().cast(), buf.capacity()); + c.check_os_err()?; + buf.set_len(c as usize); + } + Ok(()) } pub fn mkdirs(&self, mode: mode_t) -> io::Result<()> {