Thread (11 messages) 11 messages, 4 authors, 2021-08-11

Re: [PATCH v3] drivers/edac/edac_mc: Remove all strcpy() uses

From: Len Baker <hidden>
Date: 2021-08-09 16:26:25
Also in: linux-hardening, lkml

Hi,

On Mon, Aug 09, 2021 at 11:51:54AM +0200, Robert Richter wrote:
On 07.08.21 17:59:57, Len Baker wrote:
quoted
@@ -1113,11 +1115,11 @@ void edac_mc_handle_error(const enum hw_event_mc_err_type type,
 			p = e->label;
 			*p = '\0';
 		} else {
-			if (p != e->label) {
-				strcpy(p, OTHER_LABEL);
-				p += strlen(OTHER_LABEL);
-			}
-			strcpy(p, dimm->label);
+			const char *text = (p != e->label) ? OTHER_LABEL :
+				dimm->label;
+
+			strscpy(p, text, len);
+			len -= strlen(p);
The logic looks broken and dimm labels are not properly copied (the
code should add an " or " separator between labels).
Apologies. My bad.

Regards,
Len
quoted
 			p += strlen(p);
 		}
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help