diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-09-26 11:46:31 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-09-26 11:46:31 +0200 |
commit | c124b9f8b24e6cf5a3a5d5a330592ea859ba1132 (patch) | |
tree | 7b28811c8509197786fc5bfe69a3c05d99117380 | |
parent | 87378642942fa34d3061022d5e819e4b5db03ddd (diff) | |
parent | ffe4844da89587a3a5cb806abd01d61c1b4b4aa4 (diff) | |
download | plan9front-c124b9f8b24e6cf5a3a5d5a330592ea859ba1132.tar.xz |
merge
-rw-r--r-- | sys/src/cmd/cwfs/9p2.c | 11 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/con.c | 5 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/sub.c | 2 |
3 files changed, 9 insertions, 9 deletions
diff --git a/sys/src/cmd/cwfs/9p2.c b/sys/src/cmd/cwfs/9p2.c index d5f484987..0e9cc57c4 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); @@ -346,7 +348,7 @@ attach(Chan* chan, Fcall* f, Fcall* r) r->qid = file->qid; - strncpy(chan->whoname, f->uname, sizeof(chan->whoname)); + snprint(chan->whoname, sizeof(chan->whoname), "%s", f->uname); chan->whotime = time(nil); out: if(p != nil) @@ -911,7 +913,7 @@ fs_create(Chan* chan, Fcall* f, Fcall* r) goto phase; } - strncpy(d1->name, f->name, sizeof(d1->name)); + strncpy(d1->name, f->name, NAMELEN); if(chan == cons.chan){ d1->uid = cons.uid; d1->gid = cons.gid; @@ -1012,7 +1014,6 @@ fs_read(Chan* chan, Fcall* f, Fcall* r, uchar* data) } iounit = chan->msize-IOHDRSZ; if(count < 0 || count > iounit){ -fprint(2, "fs_read %d %d\n", count, iounit); error = Ecount; goto out; } @@ -1784,7 +1785,7 @@ fs_wstat(Chan* chan, Fcall* f, Fcall*, char* strs) } d->size = dir.length; if(dir.name != d->name) - strncpy(d->name, dir.name, sizeof(d->name)); + strncpy(d->name, dir.name, NAMELEN); d->uid = uid; d->gid = gid; d->muid = muid; diff --git a/sys/src/cmd/cwfs/con.c b/sys/src/cmd/cwfs/con.c index ea1154b58..9e1e7bc05 100644 --- a/sys/src/cmd/cwfs/con.c +++ b/sys/src/cmd/cwfs/con.c @@ -14,7 +14,7 @@ consserve(void) { int i; - strncpy(cons.chan->whochan, "console", sizeof(cons.chan->whochan)); + snprint(cons.chan->whochan, sizeof(cons.chan->whochan), "console"); installcmds(); con_session(); cmd_exec("cfs"); @@ -312,8 +312,7 @@ cmd_who(int argc, char *argv[]) continue; } } - print("%3d: %10s %24s", cp->chan, - cp->whoname? cp->whoname: "<nowhoname>", cp->whochan); + print("%3d: %10s %24s", cp->chan, cp->whoname, cp->whochan); if(cp->whoprint) cp->whoprint(cp); print("\n"); diff --git a/sys/src/cmd/cwfs/sub.c b/sys/src/cmd/cwfs/sub.c index 0c19949a0..f7f13f2f9 100644 --- a/sys/src/cmd/cwfs/sub.c +++ b/sys/src/cmd/cwfs/sub.c @@ -46,7 +46,7 @@ fs_chaninit(int count, int data) chans = cp; cp->chan = cons.chano; cons.chano++; - strncpy(cp->whoname, "<none>", sizeof cp->whoname); + snprint(cp->whoname, sizeof(cp->whoname), "<none>"); wlock(&cp->reflock); wunlock(&cp->reflock); rlock(&cp->reflock); |