edac: Use scnprintf() for safer buffer handling
Subsystems (2)
PATCH 1/1 edac: Use scnprintf() for safer buffer handling
snprintf() is fragile when its return value will be used to append additional data to a buffer. Use scnprintf() instead.
Signed-off-by Wang Haoran (Vul337) <[email protected]>
--- drivers/edac/skx_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/edac/skx_common.c +2 -2
@@ -670,12 +670,12 @@ static void skx_mce_output_error(struct mem_ctl_info *mci, }if (res->decoded_by_adxl) { - len =snprintf (skx_msg,MSG_SIZE ,"%s%s err_code:0x%04x:0x%04x %s" , + len =scnprintf (skx_msg,MSG_SIZE ,"%s%s err_code:0x%04x:0x%04x %s" , overflow ?" OVERFLOW" :"" , (uncorrected_error && recoverable) ?" recoverable" :"" , mscod, errcode, adxl_msg); }else { - len = snprintf(skx_msg, MSG_SIZE, + len = scnprintf(skx_msg, MSG_SIZE, "%s%s err_code:0x%04x:0x%04x ProcessorSocketId:0x%x MemoryControllerId:0x%x PhysicalRankId:0x%x Row:0x%x Column:0x%x Bank:0x%x BankGroup:0x%x", overflow ? " OVERFLOW" : "", (uncorrected_error && recoverable) ? " recoverable" : "",
Signature · 1 line
2.43.0
Quoted 8 lines
From: Wang Haoran <[email protected]>
Sent: Sunday, July 13, 2025 10:58 AM
To: Luck, Tony <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]; Wang Haoran <[email protected]>
Subject: [PATCH] edac: Usescnprintf()for safer buffer handling
Quoted 6 lines
snprintf()is fragile when its return value will be used to append additional data to a buffer. Usescnprintf()instead.Signed-off-by Wang Haoran (Vul337) <[email protected]>--- drivers/edac/skx_common.c | 4 ++--
Please also replace all instances of snprintf() with scnprintf() in the file drivers/edac/i10nm_edac.c
Thanks
-Qiuxu