From 06bab2aa81e28d2a822850b89e9e161f3627704e Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jeremy@system76.com>
Date: Sat, 6 Jul 2019 19:25:05 -0600
Subject: [PATCH] Fix Redox fchdir

---
 src/platform/redox/mod.rs | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/platform/redox/mod.rs b/src/platform/redox/mod.rs
index 9da86dd9d..60976217f 100644
--- a/src/platform/redox/mod.rs
+++ b/src/platform/redox/mod.rs
@@ -283,11 +283,12 @@ impl Pal for Sys {
     }
 
     fn fchdir(fd: c_int) -> c_int {
-        let path: &mut [u8] = &mut [0; 4096];
-        if e(syscall::fpath(fd as usize, path)) == !0 {
+        let mut buf = [0; 4096];
+        let res = e(syscall::fpath(fd as usize, &mut buf));
+        if res == !0 {
             !0
         } else {
-            e(syscall::chdir(path)) as c_int
+            e(syscall::chdir(&buf[..res])) as c_int
         }
     }
 
-- 
GitLab