Skip to content

Commit

Permalink
net/ethernet/qlogic/qed: force the string buffer NULL-terminated
Browse files Browse the repository at this point in the history
strncpy() does not ensure NULL-termination when the input string
size equals to the destination buffer size 30.
The output string is passed to qed_int_deassertion_aeu_bit()
which calls DP_INFO() and relies NULL-termination.

Use strlcpy instead. The other conditional branch above strncpy()
needs no fix as snprintf() ensures NULL-termination.

This issue is identified by a Coccinelle script.

Signed-off-by: Wang Xiayang <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
xywangsjtu authored and davem330 committed Aug 3, 2019
1 parent ea443e5 commit 3690c8c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/ethernet/qlogic/qed/qed_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ static int qed_int_deassertion(struct qed_hwfn *p_hwfn,
snprintf(bit_name, 30,
p_aeu->bit_name, num);
else
strncpy(bit_name,
strlcpy(bit_name,
p_aeu->bit_name, 30);

/* We now need to pass bitmask in its
Expand Down

0 comments on commit 3690c8c

Please sign in to comment.