diff --git a/src/system/kernel/arch/x86/32/arch.S b/src/system/kernel/arch/x86/32/arch.S index 90ef56b363..68d7038be8 100644 --- a/src/system/kernel/arch/x86/32/arch.S +++ b/src/system/kernel/arch/x86/32/arch.S @@ -264,9 +264,12 @@ FUNCTION(arch_cpu_user_strlcpy): /* count remaining bytes in src */ .L_user_strlcpy_source_count: not %ecx + # %ecx was 0 and is now max xor %al,%al + movl %esi,%edi repnz scasb + movl %edi,%esi .L_user_strlcpy_source_done: movl %esi,%eax diff --git a/src/system/kernel/arch/x86/64/arch.S b/src/system/kernel/arch/x86/64/arch.S index 3f07b957d2..baf8d09f4e 100644 --- a/src/system/kernel/arch/x86/64/arch.S +++ b/src/system/kernel/arch/x86/64/arch.S @@ -251,9 +251,12 @@ FUNCTION(arch_cpu_user_strlcpy): .L_user_strlcpy_source_count: // Count remaining bytes in src not %rcx + # %rcx was 0 and is now max xor %al, %al + movl %rsi, %rdi repnz scasb + movl %rdi, %rsi .L_user_strlcpy_source_done: // Restore the old fault handler