Skip to contentSkip to conversation

early: fix possible overlapping data buffer

PATCH In review [email protected] 1 participant 1 message Mar 4, 2011 s390

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 early: fix possible overlapping data buffer

This patch fixes bugzilla #12965:
https://bugzilla.kernel.org/show_bug.cgi?id=12965

The original code contains dangerous uses of sprintf functions like sprintf(defsys_cmd, "%s EW MINSIZE=%.7iK PARMREGS=0-13", defsys_cmd, min_size), where defsys_cmd is defined as a fixed length buffer. Replace them with snprintf can fix such issues.

---
 arch/s390/kernel/early.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/s390/kernel/early.c +0 -0
arch/s390/kernel/early.c +2 -2
@@ -133,8 +133,8 @@ static noinline __init void create_kerne
 		sinitrd_pfn = PFN_DOWN(__pa(INITRD_START));
 		einitrd_pfn = PFN_UP(__pa(INITRD_START + INITRD_SIZE));
 		min_size = einitrd_pfn << 2;
-		sprintf(defsys_cmd, "%s EW %.5X-%.5X", defsys_cmd,
-		sinitrd_pfn, einitrd_pfn);
+		snprintf(defsys_cmd, sizeof(defsys_cmd), "%s EW %.5X-%.5X",
+			 defsys_cmd, sinitrd_pfn, einitrd_pfn);
 	}
 #endif