aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/mach/hurd/getcwd.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/mach/hurd/getcwd.c')
-rw-r--r--sysdeps/mach/hurd/getcwd.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sysdeps/mach/hurd/getcwd.c b/sysdeps/mach/hurd/getcwd.c
index daa67fb858..4df2524afb 100644
--- a/sysdeps/mach/hurd/getcwd.c
+++ b/sysdeps/mach/hurd/getcwd.c
@@ -229,8 +229,12 @@ _hurd_canonicalize_directory_name_internal (file_t thisdir,
free (file_name);
return NULL;
}
- file_namep = &buf[file_namep - file_name];
+ file_namep = &buf[file_namep - file_name + size / 2];
file_name = buf;
+ /* Move current contents up to the end of the buffer.
+ This is guaranteed to be non-overlapping. */
+ memcpy (file_namep, file_namep - size / 2,
+ file_name + size - file_namep);
}
}
file_namep -= d->d_namlen;