9ns: Use strlcpy() for various devices
authorBarret Rhoden <brho@cs.berkeley.edu>
Thu, 30 Mar 2017 20:26:26 +0000 (16:26 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 30 Mar 2017 20:29:42 +0000 (16:29 -0400)
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/drivers/dev/pipe.c
kern/drivers/dev/root.c
kern/drivers/dev/vars.c

index b2e24cf..9ec4133 100644 (file)
@@ -505,7 +505,7 @@ static int pipewstat(struct chan *c, uint8_t *dp, int n)
                        error(ENAMETOOLONG, ERROR_FIXME);
                if (strncmp(p->pipedir[1 + !d1].name, d->name, KNAMELEN) == 0)
                        error(EEXIST, ERROR_FIXME);
-               strncpy(p->pipedir[1 + d1].name, d->name, KNAMELEN);
+               strlcpy(p->pipedir[1 + d1].name, d->name, KNAMELEN);
        }
        if (d->mode != -1)
                p->pipedir[d1 + 1].perm = d->mode & 0777;
index 33275ca..4ed019a 100644 (file)
@@ -204,7 +204,7 @@ static int newentry(int parent)
 static int createentry(int dir, char *name, int omode, int perm)
 {
        int n = newentry(dir);
-       strncpy(roottab[n].name, name, sizeof(roottab[n].name));
+       strlcpy(roottab[n].name, name, sizeof(roottab[n].name));
        roottab[n].length = 0;
        roottab[n].perm = perm;
        /* vers is already properly set. */
index 50fc022..f056f2b 100644 (file)
@@ -234,7 +234,7 @@ static void vars_create(struct chan *c, char *name, int omode, uint32_t perm)
                new_slot = vars_dir + nr_vars;
                nr_vars *= 2;
        }
-       strncpy(new_slot->name, name, sizeof(new_slot->name));
+       strlcpy(new_slot->name, name, sizeof(new_slot->name));
        new_slot->qid.path = addr;
        new_slot->qid.vers = 0;
        new_slot->qid.type = QTFILE;