Re: [PATCH] s390/cio: replace deprecated strncpy with strscpy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


On 10/23/23 21:24, Justin Stitt wrote:
strncpy() is deprecated for use on NUL-terminated destination strings
[1] and as such we should prefer more robust and less ambiguous string

We expect both `params` and `id` to be NUL-terminated based on their
usage with format strings:

	format_node_data(iuparams, iunodeid, &lir->incident_node);
	format_node_data(auparams, aunodeid, &lir->attached_node);

	switch (lir->iq.class) {
		pr_warn("Link degraded: RS=%02x RSID=%04x IC=%02x "
			sei_area->rs, sei_area->rsid, lir->ic, iuparams,
			iunodeid, auparams, aunodeid);

NUL-padding is not required as both `params` and `id` have been memset
to 0:

	memset(params, 0, PARAMS_LEN);
	memset(id, 0, NODEID_LEN);

Considering the above, a suitable replacement is `strscpy` [2] due to
the fact that it guarantees NUL-termination on the destination buffer
without unnecessarily NUL-padding.

Note that there's no overread bugs in the current implementation as the
string literal "n/a" has a size much smaller than PARAMS_LEN or
NODEID_LEN. Nonetheless, let's favor strscpy().

Link:  [1]
Link:  [2]
Signed-off-by: Justin Stitt<justinstitt@xxxxxxxxxx>

LGTM. Thank you.

Reviewed-by: Vineeth Vijayan <vneethv@xxxxxxxxxxxxx>

I can push this to s390-tree and Heiko/Vasily will upstream it.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux