]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/9/port/netif.c
devproc: make sure /proc/n/wait waits for the right process children
[plan9front.git] / sys / src / 9 / port / netif.c
index 57e90c426a9992d3441c024c7ad6dddbeb04a1e6..e775fe847b65b0689f76f957e8ecb35aee87da0a 100644 (file)
@@ -18,8 +18,9 @@ static int parseaddr(uchar*, char*, int);
 void
 netifinit(Netif *nif, char *name, int nfile, ulong limit)
 {
-       strncpy(nif->name, name, KNAMELEN-1);
-       nif->name[KNAMELEN-1] = 0;
+       if(strlen(name) >= sizeof nif->name)
+               panic("netifinit: name too long: %s", name);
+       strcpy(nif->name, name);
        nif->nfile = nfile;
        nif->f = xalloc(nfile*sizeof(Netfile*));
        if (nif->f == nil)
@@ -66,7 +67,7 @@ netifgen(Chan *c, char*, Dirtab *vp, int, int i, Dir *dp)
 
        /* second level contains clone plus all the conversations */
        t = NETTYPE(c->qid.path);
-       if(t == N2ndqid || t == Ncloneqid || t == Naddrqid){
+       if(t == N2ndqid || t == Ncloneqid || t == Naddrqid || t == Nstatqid || t == Nifstatqid){
                switch(i) {
                case DEVDOTDOT:
                        q.type = QTDIR;
@@ -374,8 +375,10 @@ netifwstat(Netif *nif, Chan *c, uchar *db, int n)
                free(dir);
                error(Eshortstat);
        }
-       if(!emptystr(dir[0].uid))
-               strncpy(f->owner, dir[0].uid, KNAMELEN);
+       if(!emptystr(dir[0].uid)){
+               strncpy(f->owner, dir[0].uid, KNAMELEN-1);
+               f->owner[KNAMELEN-1] = 0;
+       }
        if(dir[0].mode != ~0UL)
                f->mode = dir[0].mode;
        free(dir);
@@ -471,7 +474,8 @@ netown(Netfile *p, char *o, int omode)
                        return -1;
                }
        }
-       strncpy(p->owner, o, KNAMELEN);
+       strncpy(p->owner, o, KNAMELEN-1);
+       p->owner[KNAMELEN-1] = 0;
        p->mode = 0660;
        unlock(&netlock);
        return 0;