mirror of
https://github.com/torvalds/linux.git
synced 2024-11-25 13:41:51 +00:00
9dd12ed95c
strncpy() is deprecated for use on NUL-terminated destination strings
[1] and as such we should prefer more robust and less ambiguous string
interfaces.
We know that info-device should be NUL-terminated based on its use with
strlen():
| static int __init mtdpstore_init(void)
| {
| int ret;
| struct mtdpstore_context *cxt = &oops_cxt;
| struct pstore_blk_config *info = &cxt->info;
|
| ret = pstore_blk_get_config(info);
| if (unlikely(ret))
| return ret;
|
| if (strlen(info->device) == 0) {
| pr_err("mtd device must be supplied (device name is empty)\n");
...
Considering the above, a suitable replacement is `strscpy` [2] due to
the fact that it guarantees NUL-termination on the destination buffer.
Note that this patch relies on the _new_ 2-argument version of strscpy()
introduced in Commit
|
||
---|---|---|
.. | ||
blk.c | ||
ftrace.c | ||
inode.c | ||
internal.h | ||
Kconfig | ||
Makefile | ||
platform.c | ||
pmsg.c | ||
ram_core.c | ||
ram_internal.h | ||
ram.c | ||
zone.c |