Commit f5a6fa18 authored by Josephine Pfeiffer's avatar Josephine Pfeiffer Committed by Janosch Frank
Browse files

KVM: s390: Replace sprintf with snprintf for buffer safety



Replace sprintf() with snprintf() when formatting debug names to prevent
potential buffer overflow. The debug_name buffer is 16 bytes, and while
unlikely to overflow with current PIDs, using snprintf() provides proper
bounds checking.

Signed-off-by: default avatarJosephine Pfeiffer <hi@josie.lol>
[frankja@linux.ibm.com: Fixed subject prefix]
Signed-off-by: default avatarJanosch Frank <frankja@linux.ibm.com>
parent 7d5136ed
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3348,7 +3348,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
	if (!kvm->arch.sca)
		goto out_err;

	sprintf(debug_name, "kvm-%u", current->pid);
	snprintf(debug_name, sizeof(debug_name), "kvm-%u", current->pid);

	kvm->arch.dbf = debug_register(debug_name, 32, 1, 7 * sizeof(long));
	if (!kvm->arch.dbf)