Skip to contentSkip to conversation

sparc: fix ldom_reboot buffer overflow harder

PATCH New Kees Cook 1 participant 1 message Oct 2, 2013 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 sparc: fix ldom_reboot buffer overflow harder

The length argument to strlcpy was still wrong. It could overflow the end of full_boot_str by 5 bytes. Instead of strcat and strlcpy, just use snprint.

---
 arch/sparc/kernel/ds.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/sparc/kernel/ds.c +2 -3
index 4d9ac84..dff60ab 100644
@@ -849,9 +849,8 @@ void ldom_reboot(const char *boot_command)
 	if (boot_command && strlen(boot_command)) {
 		unsigned long len;
 
-		strcpy(full_boot_str, "boot ");
-		strlcpy(full_boot_str + strlen("boot "), boot_command,
-			sizeof(full_boot_str));
+		snprintf(full_boot_str, sizeof(full_boot_str), "boot %s",
+			 boot_command);
 		len = strlen(full_boot_str);
 
 		if (reboot_data_supported) {
Signature · 6 lines
1.7.9.5


-- 
Kees Cook
Chrome OS Security