ref: ac3e3c342fc32cd633599d85391827289b7ebdf5
parent: a7ab8158395039091ef1bad3f18748b77b9a4cdc
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Feb 24 23:08:13 EST 2019
hgfs: fix %.*s usage in walk
--- a/sys/src/cmd/hgfs/fs.c
+++ b/sys/src/cmd/hgfs/fs.c
@@ -499,13 +499,13 @@
if(nd == nil){
if(sname == name){
sname = strrchr(name, '.');
- if((i = sname - name) > 0){
+ if(sname && (i = utfnlen(name, sname - name)) > 0){
+ snprint(buf, sizeof(buf), "%.*s", i, name);
sname++;
if(strncmp(sname, "rev", 3) == 0){
level = Qtreerev;
sname += 3;
}
- snprint(buf, sizeof(buf), "%.*s", i, name);
if(*sname == 0)
i = 0;
else {