Thread (3 messages) 3 messages, 2 authors, 2021-08-02

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

From: Robert Richter <rric@kernel.org>
Date: 2021-08-02 09:19:35
Also in: linux-hardening, lkml

On 01.08.21 16:35:58, Len Baker wrote:
quoted hunk ↗ jump to hunk
@@ -1114,10 +1116,12 @@ void edac_mc_handle_error(const enum hw_event_mc_err_type type,
 			*p = '\0';
 		} else {
 			if (p != e->label) {
-				strcpy(p, OTHER_LABEL);
+				strscpy(p, OTHER_LABEL, left);
+				left -= strlen(OTHER_LABEL);
 				p += strlen(OTHER_LABEL);
Those both must be strlen(p) now as otherwise 'left' could underflow
(and p overflow).

-Robert
 			}
-			strcpy(p, dimm->label);
+			strscpy(p, dimm->label, left);
+			left -= strlen(p);
 			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