diff options
author | Len Baker <len.baker@gmx.com> | 2021-08-17 19:58:59 +0300 |
---|---|---|
committer | Wolfram Sang <wsa@kernel.org> | 2021-08-17 22:37:40 +0300 |
commit | e47a0ced40472cfbe3e77502098ad489ba16bf97 (patch) | |
tree | d1d7aac5c63412401fad120fe889fcb2ac993d9d /drivers/i2c/busses/i2c-sun6i-p2wi.c | |
parent | e517992bbce06228f07b9bbea3233cc0fb04e802 (diff) | |
download | linux-e47a0ced40472cfbe3e77502098ad489ba16bf97.tar.xz |
i2c: sun6i-pw2i: Prefer strscpy over strlcpy
strlcpy() reads the entire source buffer first. This read may exceed the
destination size limit. This is both inefficient and can lead to linear
read overflows if a source string is not NUL-terminated. The safe
replacement is strscpy().
This is a previous step in the path to remove the strlcpy() function
entirely from the kernel [1].
[1] https://github.com/KSPP/linux/issues/89
Signed-off-by: Len Baker <len.baker@gmx.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Diffstat (limited to 'drivers/i2c/busses/i2c-sun6i-p2wi.c')
-rw-r--r-- | drivers/i2c/busses/i2c-sun6i-p2wi.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/i2c/busses/i2c-sun6i-p2wi.c b/drivers/i2c/busses/i2c-sun6i-p2wi.c index 2f6f6468214d..9e3483f507ff 100644 --- a/drivers/i2c/busses/i2c-sun6i-p2wi.c +++ b/drivers/i2c/busses/i2c-sun6i-p2wi.c @@ -234,7 +234,7 @@ static int p2wi_probe(struct platform_device *pdev) if (IS_ERR(p2wi->regs)) return PTR_ERR(p2wi->regs); - strlcpy(p2wi->adapter.name, pdev->name, sizeof(p2wi->adapter.name)); + strscpy(p2wi->adapter.name, pdev->name, sizeof(p2wi->adapter.name)); irq = platform_get_irq(pdev, 0); if (irq < 0) return irq; |