提交 286b63d0 编写于 作者: R Roel Kluin 提交者: Roland Dreier

IB/ipath: strncpy() doesn't always NUL-terminate

strlcpy() will always null terminate the string.  node_desc is not
guaranteed to be NUL-terminated so just use memcpy().
Signed-off-by: NRoel Kluin <roel.kluin@gmail.com>
Signed-off-by: NRoland Dreier <rolandd@cisco.com>
上级 e07cccf4
...@@ -1616,7 +1616,7 @@ static int try_alloc_port(struct ipath_devdata *dd, int port, ...@@ -1616,7 +1616,7 @@ static int try_alloc_port(struct ipath_devdata *dd, int port,
pd->port_cnt = 1; pd->port_cnt = 1;
port_fp(fp) = pd; port_fp(fp) = pd;
pd->port_pid = get_pid(task_pid(current)); 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++; ipath_stats.sps_ports++;
ret = 0; ret = 0;
} else } else
......
...@@ -60,7 +60,7 @@ static int recv_subn_get_nodedescription(struct ib_smp *smp, ...@@ -60,7 +60,7 @@ static int recv_subn_get_nodedescription(struct ib_smp *smp,
if (smp->attr_mod) if (smp->attr_mod)
smp->status |= IB_SMP_INVALID_FIELD; 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); return reply(smp);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册