]> git.lizzy.rs Git - plan9front.git/commitdiff
cwfs: don't use sprint() to fill directory name
authorcinap_lenrek <cinap_lenrek@felloff.net>
Sat, 26 Sep 2015 09:41:31 +0000 (11:41 +0200)
committercinap_lenrek <cinap_lenrek@felloff.net>
Sat, 26 Sep 2015 09:41:31 +0000 (11:41 +0200)
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

index d5f484987ae8c07743059b53c3cf0fce64cde5b5..6ead02645aed8ff32ad2b4788b18938349db02ea 100644 (file)
@@ -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);