From 76e0968e35f03ec848093072458e3d15bee2f372 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sat, 26 Sep 2015 11:41:31 +0200 Subject: cwfs: don't use sprint() to fill directory name sprint() will replace invalid utf8 sequences with U+FFFD which caused directory reads and stats to return the wrong filename. just strcpy the name bytes. --- sys/src/cmd/cwfs/9p2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/src/cmd/cwfs/9p2.c b/sys/src/cmd/cwfs/9p2.c index d5f484987..6ead02645 100644 --- a/sys/src/cmd/cwfs/9p2.c +++ b/sys/src/cmd/cwfs/9p2.c @@ -93,7 +93,9 @@ mkdir9p2(Dir* dir, Dentry* dentry, void* strs) op = p = strs; dir->name = p; - p += sprint(p, "%s", dentry->name)+1; + strncpy(p, dentry->name, NAMELEN); + p[NAMELEN-1] = 0; + p += strlen(p)+1; dir->uid = p; uidtostr(p, dentry->uid, 1); -- cgit v1.2.3