shithub: riscv

Download patch

ref: 76e0968e35f03ec848093072458e3d15bee2f372
parent: fc06f637cff6d812207fb798b48a31ab463f0ab5
author: cinap_lenrek <[email protected]>
date: Sat Sep 26 07:41:31 EDT 2015

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.

--- a/sys/src/cmd/cwfs/9p2.c
+++ b/sys/src/cmd/cwfs/9p2.c
@@ -93,7 +93,9 @@
 
 	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);