This commit is contained in:
John Maddock
2018-07-18 18:30:14 +01:00
parent 35fbb2e5e2
commit ac49efa23f

View File

@ -198,9 +198,10 @@ namespace boost{ namespace BOOST_REGEX_DETAIL_NS{
const char *strSource
)
{
if(std::strlen(strSource)+1 > sizeInBytes)
std::size_t lenSourceWithNull = std::strlen(strSource) + 1;
if (lenSourceWithNull > sizeInBytes)
return 1;
std::strcpy(strDestination, strSource);
std::memcpy(strDestination, strSource, lenSourceWithNull);
return 0;
}
inline std::size_t strcat_s(
@ -209,9 +210,11 @@ namespace boost{ namespace BOOST_REGEX_DETAIL_NS{
const char *strSource
)
{
if(std::strlen(strSource) + std::strlen(strDestination) + 1 > sizeInBytes)
std::size_t lenSourceWithNull = std::strlen(strSource) + 1;
std::size_t lenDestination = std::strlen(strDestination);
if (lenSourceWithNull + lenDestination > sizeInBytes)
return 1;
std::strcat(strDestination, strSource);
std::memcpy(strDestination + lenDestination, strSource, lenSourceWithNull);
return 0;
}