mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Fix wmemmove(3) off-by-one bounds error.
This commit is contained in:
parent
c0ad3d8a80
commit
86cd065aa7
1 changed files with 6 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
|
||||||
|
|
||||||
This file is part of the Sortix C Library.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
|
@ -28,10 +28,14 @@
|
||||||
extern "C" wchar_t* wmemmove(wchar_t* dst, const wchar_t* src, size_t n)
|
extern "C" wchar_t* wmemmove(wchar_t* dst, const wchar_t* src, size_t n)
|
||||||
{
|
{
|
||||||
if ( (uintptr_t) dst < (uintptr_t) src )
|
if ( (uintptr_t) dst < (uintptr_t) src )
|
||||||
|
{
|
||||||
for ( size_t i = 0; i < n; i++ )
|
for ( size_t i = 0; i < n; i++ )
|
||||||
dst[i] = src[i];
|
dst[i] = src[i];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
for ( size_t i = 0; i < n; i++ )
|
for ( size_t i = 0; i < n; i++ )
|
||||||
dst[n-i] = src[n-i];
|
dst[n-(i+1)] = src[n-(i+1)];
|
||||||
|
}
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue