mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-24 13:53:36 +02:00
Fix potential string truncation error
This commit is contained in:
1 parent
d536b3d2cc
commit
b63eddd4cd
3 files changed
+11
-5
No files matched your search
@@ -35,8 +35,8 @@ namespace
|
||||
// Helper function for converting a SFML address to a CSFML one
|
||||
sfIpAddress fromSFMLAddress(sf::IpAddress address)
|
||||
{
|
||||
sfIpAddress result;
|
||||
strncpy(result.address, address.toString().c_str(), 16);
|
||||
sfIpAddress result = {0};
|
||||
strncpy(result.address, address.toString().c_str(), 15);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ sfIpAddress sfTcpSocket_getRemoteAddress(const sfTcpSocket* socket)
|
||||
CSFML_CHECK_RETURN(socket, result);
|
||||
|
||||
sf::IpAddress address = socket->This.getRemoteAddress();
|
||||
strncpy(result.address, address.toString().c_str(), 16);
|
||||
strncpy(result.address, address.toString().c_str(), 15);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,10 @@ sfSocketStatus sfUdpSocket_receive(sfUdpSocket* socket, void* data, size_t size,
|
||||
*received = sizeReceived;
|
||||
|
||||
if (remoteAddress)
|
||||
strncpy(remoteAddress->address, address.toString().c_str(), 16);
|
||||
{
|
||||
*remoteAddress = sfIpAddress_None;
|
||||
strncpy(remoteAddress->address, address.toString().c_str(), 15);
|
||||
}
|
||||
|
||||
if (remotePort)
|
||||
*remotePort = port;
|
||||
@@ -149,7 +152,10 @@ sfSocketStatus sfUdpSocket_receivePacket(sfUdpSocket* socket, sfPacket* packet,
|
||||
return static_cast<sfSocketStatus>(status);
|
||||
|
||||
if (remoteAddress)
|
||||
strncpy(remoteAddress->address, address.toString().c_str(), 16);
|
||||
{
|
||||
*remoteAddress = sfIpAddress_None;
|
||||
strncpy(remoteAddress->address, address.toString().c_str(), 15);
|
||||
}
|
||||
|
||||
if (remotePort)
|
||||
*remotePort = port;
|
||||
|
||||
Reference in new issue
Block a user