Skip to content

Commit

Permalink
IB/ipath: strncpy() doesn't always NUL-terminate
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Roland Dreier <[email protected]>
  • Loading branch information
RoelKluin authored and Roland Dreier committed Sep 6, 2009
1 parent e07cccf commit 286b63d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/infiniband/hw/ipath/ipath_file_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/hw/ipath/ipath_mad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 286b63d

Please sign in to comment.