summaryrefslogtreecommitdiff
path: root/sys/src
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@rei2.9hal>2012-02-08 02:32:03 +0100
committercinap_lenrek <cinap_lenrek@rei2.9hal>2012-02-08 02:32:03 +0100
commit061d55111b677de4810fa8fd4a8f05907adaef8b (patch)
treeb07183d6086debf1767aa11a6ea9db9354dd0fc0 /sys/src
parent022fd02b9632b0ca3ddd9547730446dd222ab93d (diff)
add Etoolong error string, cleanup genbuf truncation fix
Diffstat (limited to 'sys/src')
-rw-r--r--sys/src/9/port/devenv.c4
-rw-r--r--sys/src/9/port/devflash.c3
-rw-r--r--sys/src/9/port/devshr.c12
-rw-r--r--sys/src/9/port/devsrv.c8
-rw-r--r--sys/src/9/port/error.h1
5 files changed, 15 insertions, 13 deletions
diff --git a/sys/src/9/port/devenv.c b/sys/src/9/port/devenv.c
index 0bb26dcf8..e7100aa4a 100644
--- a/sys/src/9/port/devenv.c
+++ b/sys/src/9/port/devenv.c
@@ -48,7 +48,7 @@ envgen(Chan *c, char *name, Dirtab*, int, int s, Dir *dp)
else if(s < eg->nent)
e = eg->ent[s];
- if(e == 0 || (strlen(e->name) >= sizeof(up->genbuf))) {
+ if(e == 0 || name && (strlen(e->name) >= sizeof(up->genbuf))) {
runlock(eg);
return -1;
}
@@ -148,7 +148,7 @@ envcreate(Chan *c, char *name, int omode, ulong)
error(Eperm);
if(strlen(name) >= sizeof(up->genbuf))
- error(Egreg);
+ error(Etoolong);
omode = openmode(omode);
eg = envgrp(c);
diff --git a/sys/src/9/port/devflash.c b/sys/src/9/port/devflash.c
index 28b0808e0..80a115424 100644
--- a/sys/src/9/port/devflash.c
+++ b/sys/src/9/port/devflash.c
@@ -403,7 +403,8 @@ flashnewpart(Flash *f, char *name, ulong start, ulong end)
}
if((fp = empty) == nil)
return "partition table full";
-// fp->name = nil;
+ if(strlen(name)+3 >= sizeof(up->genbuf))
+ return Etoolong;
kstrdup(&fp->name, name);
if(fp->name == nil)
return Enomem;
diff --git a/sys/src/9/port/devshr.c b/sys/src/9/port/devshr.c
index f6ef0ae9a..70c477d53 100644
--- a/sys/src/9/port/devshr.c
+++ b/sys/src/9/port/devshr.c
@@ -304,7 +304,7 @@ shrgen(Chan *c, char*, Dirtab*, int, int s, Dir *dp)
qlock(&shrslk);
for(shr = shrs; shr && s; shr = shr->next)
s--;
- if(shr == nil || (strlen(shr->name) >= sizeof(up->genbuf))){
+ if(shr == nil){
qunlock(&shrslk);
return -1;
}
@@ -323,11 +323,11 @@ shrgen(Chan *c, char*, Dirtab*, int, int s, Dir *dp)
rlock(&h->lock);
for(m = h->mount; m && s; m = m->next)
s--;
- mpt = tompt(m);
- if(m == nil || (strlen(mpt->name) >= sizeof(up->genbuf))){
+ if(m == nil){
runlock(&h->lock);
return -1;
}
+ mpt = tompt(m);
kstrcpy(up->genbuf, mpt->name, sizeof up->genbuf);
devdir(c, shrqid(Qcmpt, mpt->id), up->genbuf, 0, mpt->owner, mpt->perm, dp);
runlock(&h->lock);
@@ -461,7 +461,7 @@ shrcreate(Chan *c, char *name, int omode, ulong perm)
if((perm & DMDIR) == 0 || openmode(omode) != OREAD)
error(Eperm);
if(strlen(name) >= sizeof(up->genbuf))
- error(Egreg);
+ error(Etoolong);
qlock(&shrslk);
if(waserror()){
qunlock(&shrslk);
@@ -499,7 +499,7 @@ shrcreate(Chan *c, char *name, int omode, ulong perm)
devpermcheck(shr->owner, shr->perm, ORDWR);
if(strlen(name) >= sizeof(up->genbuf))
- error(Egreg);
+ error(Etoolong);
h = &shr->umh;
wlock(&h->lock);
@@ -657,7 +657,7 @@ shrwstat(Chan *c, uchar *dp, int n)
if(strchr(d.name, '/') != nil)
error(Ebadchar);
if(strlen(d.name) >= sizeof(up->genbuf))
- error(Egreg);
+ error(Etoolong);
kstrdup(&ent->name, d.name);
}
poperror();
diff --git a/sys/src/9/port/devsrv.c b/sys/src/9/port/devsrv.c
index adde67b9b..982e96cb3 100644
--- a/sys/src/9/port/devsrv.c
+++ b/sys/src/9/port/devsrv.c
@@ -49,7 +49,7 @@ srvgen(Chan *c, char *name, Dirtab*, int, int s, Dir *dp)
for(sp = srv; sp && s; sp = sp->link)
s--;
}
- if(sp == 0 || (strlen(sp->name) >= sizeof(up->genbuf))) {
+ if(sp == 0 || name && (strlen(sp->name) >= sizeof(up->genbuf))) {
qunlock(&srvlk);
return -1;
}
@@ -148,7 +148,7 @@ srvcreate(Chan *c, char *name, int omode, ulong perm)
error(Eperm);
if(strlen(name) >= sizeof(up->genbuf))
- error(Egreg);
+ error(Etoolong);
sp = smalloc(sizeof *sp);
sname = smalloc(strlen(name)+1);
@@ -266,7 +266,7 @@ srvwstat(Chan *c, uchar *dp, int n)
if(strchr(d.name, '/') != nil)
error(Ebadchar);
if(strlen(d.name) >= sizeof(up->genbuf))
- error(Egreg);
+ error(Etoolong);
kstrdup(&sp->name, d.name);
}
qunlock(&srvlk);
@@ -307,7 +307,7 @@ srvwrite(Chan *c, void *va, long n, vlong)
char buf[32];
if(n >= sizeof buf)
- error(Egreg);
+ error(Etoobig);
memmove(buf, va, n); /* so we can NUL-terminate */
buf[n] = 0;
fd = strtoul(buf, 0, 0);
diff --git a/sys/src/9/port/error.h b/sys/src/9/port/error.h
index e9a4367dc..215ae7ee1 100644
--- a/sys/src/9/port/error.h
+++ b/sys/src/9/port/error.h
@@ -51,3 +51,4 @@ extern char Enegoff[]; /* negative i/o offset */
extern char Ecmdargs[]; /* wrong #args in control message */
extern char Ebadip[]; /* bad ip address syntax */
extern char Edirseek[]; /* seek in directory */
+extern char Etoolong[]; /* name too long */