Modify bcopy (and memcpy/memmove) so that the length value is not
re-read from the stack mid copy. This may help mitigate the recent Apache buffer overrun and future overruns of the sort. Reviewed by: jdp MFC after: 2 days
This commit is contained in:
parent
80536ead7f
commit
1228a1c634
@ -69,10 +69,11 @@ ENTRY(bcopy)
|
||||
cmpl %ecx,%eax /* overlapping? */
|
||||
jb 1f
|
||||
cld /* nope, copy forwards. */
|
||||
movl %ecx, %eax
|
||||
shrl $2,%ecx /* copy by words */
|
||||
rep
|
||||
movsl
|
||||
movl 20(%esp),%ecx
|
||||
movl %eax, %ecx
|
||||
andl $3,%ecx /* any bytes left? */
|
||||
rep
|
||||
movsb
|
||||
@ -86,12 +87,13 @@ ENTRY(bcopy)
|
||||
addl %ecx,%edi /* copy backwards. */
|
||||
addl %ecx,%esi
|
||||
std
|
||||
movl %ecx, %eax
|
||||
andl $3,%ecx /* any fractional bytes? */
|
||||
decl %edi
|
||||
decl %esi
|
||||
rep
|
||||
movsb
|
||||
movl 20(%esp),%ecx /* copy remainder by words */
|
||||
movl %eax, %ecx /* copy remainder by words */
|
||||
shrl $2,%ecx
|
||||
subl $3,%esi
|
||||
subl $3,%edi
|
||||
|
Loading…
x
Reference in New Issue
Block a user