IB/ipath: strncpy() doesn't always NUL-terminate
authorRoel Kluin <roel.kluin@gmail.com>
Sun, 6 Sep 2009 03:23:21 +0000 (20:23 -0700)
committerRoland Dreier <rolandd@cisco.com>
Sun, 6 Sep 2009 03:23:21 +0000 (20:23 -0700)
strlcpy() will always null terminate the string.  node_desc is not
guaranteed to be NUL-terminated so just use memcpy().

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/hw/ipath/ipath_file_ops.c
drivers/infiniband/hw/ipath/ipath_mad.c

index 23173982b32c1c636fdc2bbc398ad1168e3ff10d..38a287006612c055b3a1faa32800099041257c35 100644 (file)
@@ -1616,7 +1616,7 @@ static int try_alloc_port(struct ipath_devdata *dd, int port,
                pd->port_cnt = 1;
                port_fp(fp) = pd;
                pd->port_pid = get_pid(task_pid(current));
-               strncpy(pd->port_comm, current->comm, sizeof(pd->port_comm));
+               strlcpy(pd->port_comm, current->comm, sizeof(pd->port_comm));
                ipath_stats.sps_ports++;
                ret = 0;
        } else
index 16a702d460184f8f66e2434b720aa9842a145701..ceb98ee7866646d87ecdc6b8351622a11441facd 100644 (file)
@@ -60,7 +60,7 @@ static int recv_subn_get_nodedescription(struct ib_smp *smp,
        if (smp->attr_mod)
                smp->status |= IB_SMP_INVALID_FIELD;
 
-       strncpy(smp->data, ibdev->node_desc, sizeof(smp->data));
+       memcpy(smp->data, ibdev->node_desc, sizeof(smp->data));
 
        return reply(smp);
 }