diff options
author | Xu Panda <xu.panda@zte.com.cn> | 2022-12-23 10:40:56 +0800 |
---|---|---|
committer | Helge Deller <deller@gmx.de> | 2023-01-09 09:51:56 +0100 |
commit | f2193bb2ee6e21d9c2da10ea3ce63b94aea69341 (patch) | |
tree | 8c4f8bad17bfae6f6741862282242635ca0a7600 | |
parent | b7bfaa761d760e72a969d116517eaa12e404c262 (diff) | |
download | linux-stable-f2193bb2ee6e21d9c2da10ea3ce63b94aea69341.tar.gz linux-stable-f2193bb2ee6e21d9c2da10ea3ce63b94aea69341.tar.bz2 linux-stable-f2193bb2ee6e21d9c2da10ea3ce63b94aea69341.zip |
parisc: pdc_stable: use strscpy() to instead of strncpy()
The implementation of strscpy() is more robust and safer.
That's now the recommended way to copy NUL-terminated strings.
Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
Signed-off-by: Yang Yang <yang.yang29@zte.com>
Signed-off-by: Helge Deller <deller@gmx.de>
-rw-r--r-- | drivers/parisc/pdc_stable.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c index d6af5726ddf3..2a18f7ba2398 100644 --- a/drivers/parisc/pdc_stable.c +++ b/drivers/parisc/pdc_stable.c @@ -274,8 +274,7 @@ pdcspath_hwpath_write(struct pdcspath_entry *entry, const char *buf, size_t coun /* We'll use a local copy of buf */ count = min_t(size_t, count, sizeof(in)-1); - strncpy(in, buf, count); - in[count] = '\0'; + strscpy(in, buf, count + 1); /* Let's clean up the target. 0xff is a blank pattern */ memset(&hwpath, 0xff, sizeof(hwpath)); @@ -388,8 +387,7 @@ pdcspath_layer_write(struct pdcspath_entry *entry, const char *buf, size_t count /* We'll use a local copy of buf */ count = min_t(size_t, count, sizeof(in)-1); - strncpy(in, buf, count); - in[count] = '\0'; + strscpy(in, buf, count + 1); /* Let's clean up the target. 0 is a blank pattern */ memset(&layers, 0, sizeof(layers)); @@ -756,8 +754,7 @@ static ssize_t pdcs_auto_write(struct kobject *kobj, /* We'll use a local copy of buf */ count = min_t(size_t, count, sizeof(in)-1); - strncpy(in, buf, count); - in[count] = '\0'; + strscpy(in, buf, count + 1); /* Current flags are stored in primary boot path entry */ pathentry = &pdcspath_entry_primary; |