mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-28 21:56:12 +01: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
|
// Helper function for converting a SFML address to a CSFML one
|
||||||
sfIpAddress fromSFMLAddress(sf::IpAddress address)
|
sfIpAddress fromSFMLAddress(sf::IpAddress address)
|
||||||
{
|
{
|
||||||
sfIpAddress result;
|
sfIpAddress result = {0};
|
||||||
strncpy(result.address, address.toString().c_str(), 16);
|
strncpy(result.address, address.toString().c_str(), 15);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ sfIpAddress sfTcpSocket_getRemoteAddress(const sfTcpSocket* socket)
|
|||||||
CSFML_CHECK_RETURN(socket, result);
|
CSFML_CHECK_RETURN(socket, result);
|
||||||
|
|
||||||
sf::IpAddress address = socket->This.getRemoteAddress();
|
sf::IpAddress address = socket->This.getRemoteAddress();
|
||||||
strncpy(result.address, address.toString().c_str(), 16);
|
strncpy(result.address, address.toString().c_str(), 15);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,10 @@ sfSocketStatus sfUdpSocket_receive(sfUdpSocket* socket, void* data, size_t size,
|
|||||||
*received = sizeReceived;
|
*received = sizeReceived;
|
||||||
|
|
||||||
if (remoteAddress)
|
if (remoteAddress)
|
||||||
strncpy(remoteAddress->address, address.toString().c_str(), 16);
|
{
|
||||||
|
*remoteAddress = sfIpAddress_None;
|
||||||
|
strncpy(remoteAddress->address, address.toString().c_str(), 15);
|
||||||
|
}
|
||||||
|
|
||||||
if (remotePort)
|
if (remotePort)
|
||||||
*remotePort = port;
|
*remotePort = port;
|
||||||
@@ -149,7 +152,10 @@ sfSocketStatus sfUdpSocket_receivePacket(sfUdpSocket* socket, sfPacket* packet,
|
|||||||
return static_cast<sfSocketStatus>(status);
|
return static_cast<sfSocketStatus>(status);
|
||||||
|
|
||||||
if (remoteAddress)
|
if (remoteAddress)
|
||||||
strncpy(remoteAddress->address, address.toString().c_str(), 16);
|
{
|
||||||
|
*remoteAddress = sfIpAddress_None;
|
||||||
|
strncpy(remoteAddress->address, address.toString().c_str(), 15);
|
||||||
|
}
|
||||||
|
|
||||||
if (remotePort)
|
if (remotePort)
|
||||||
*remotePort = port;
|
*remotePort = port;
|
||||||
|
|||||||
Reference in new issue
Block a user