Skip to contentSkip to conversation

sparc64: Fix buggy strlcpy() conversion in ldom_reboot().

PATCH New David Miller 1 participant 1 message Sep 27, 2013 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore

David Miller

author maintainer
#0 lore raw

PATCH 1/1 sparc64: Fix buggy strlcpy() conversion in ldom_reboot().

Commit 117a0c5fc9c2d06045bd217385b2b39ea426b5a6 ("sparc: kernel: using strlcpy() instead of strcpy()") added a bug to ldom_reboot in arch/sparc/kernel/ds.c

- strcpy(full_boot_str + strlen("boot "), boot_command);
+ strlcpy(full_boot_str + strlen("boot "), boot_command,
+ sizeof(full_boot_str + strlen("boot ")));

That last sizeof() expression evaluates to sizeof(size_t) which is not what was intended.

Also even the corrected:

sizeof(full_boot_str) + strlen("boot ")

is not right as the destination buffer length is just plain "sizeof(full_boot_str)" and that's what the final argument should be.

---

I'll push this to -stable too since 3.9 and onward need this fix as well.

 arch/sparc/kernel/ds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/kernel/ds.c +1 -1
index 62d6b15..4d9ac84 100644
@@ -851,7 +851,7 @@ void ldom_reboot(const char *boot_command)
 
 		strcpy(full_boot_str, "boot ");
 		strlcpy(full_boot_str + strlen("boot "), boot_command,
-			sizeof(full_boot_str + strlen("boot ")));
+			sizeof(full_boot_str));
 		len = strlen(full_boot_str);
 
 		if (reboot_data_supported) {
Signature · 1 line
1.7.11.7