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)
/* 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;
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);
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;