enet: Sync with upstream commit c44b7d0

c44b7d0f7f
(cherry picked from commit 360a1a4568)
This commit is contained in:
Rémi Verschelde 2024-04-05 10:12:29 +02:00
parent 9a2e88aa01
commit 48f9059f12
No known key found for this signature in database
GPG Key ID: C3336907360768E1
3 changed files with 21 additions and 15 deletions

View File

@ -71,8 +71,8 @@ commits.
## enet ## enet
- Upstream: http://enet.bespin.org - Upstream: https://github.com/lsalzman/enet
- Version: git (ea4607a90dbfbcf4da2669ea998585253d8e70b1, 2023) - Version: git (c44b7d0f7ff21edb702745e4c019d0537928c373, 2024)
- License: MIT - License: MIT
Files extracted from upstream source: Files extracted from upstream source:

View File

@ -1,5 +1,5 @@
diff --git a/thirdparty/enet/enet/enet.h b/thirdparty/enet/enet/enet.h diff --git a/thirdparty/enet/enet/enet.h b/thirdparty/enet/enet/enet.h
index fc45cbd0c9..77f8004b80 100644 index 4a207041b3..5232f8a869 100644
--- a/thirdparty/enet/enet/enet.h --- a/thirdparty/enet/enet/enet.h
+++ b/thirdparty/enet/enet/enet.h +++ b/thirdparty/enet/enet/enet.h
@@ -10,13 +10,19 @@ extern "C" @@ -10,13 +10,19 @@ extern "C"
@ -22,7 +22,7 @@ index fc45cbd0c9..77f8004b80 100644
#include "enet/types.h" #include "enet/types.h"
#include "enet/protocol.h" #include "enet/protocol.h"
@@ -86,11 +92,15 @@ typedef enum _ENetSocketShutdown @@ -87,11 +93,15 @@ typedef enum _ENetSocketShutdown
* but not for enet_host_create. Once a server responds to a broadcast, the * but not for enet_host_create. Once a server responds to a broadcast, the
* address is updated from ENET_HOST_BROADCAST to the server's actual IP address. * address is updated from ENET_HOST_BROADCAST to the server's actual IP address.
*/ */
@ -38,7 +38,7 @@ index fc45cbd0c9..77f8004b80 100644
/** /**
* Packet flag bit constants. * Packet flag bit constants.
@@ -604,6 +614,10 @@ ENET_API size_t enet_range_coder_decompress (void *, const enet_uint8 *, size_t, @@ -608,6 +618,10 @@ ENET_API size_t enet_range_coder_decompress (void *, const enet_uint8 *, size_t,
extern size_t enet_protocol_command_size (enet_uint8); extern size_t enet_protocol_command_size (enet_uint8);
@ -50,7 +50,7 @@ index fc45cbd0c9..77f8004b80 100644
} }
#endif #endif
diff --git a/thirdparty/enet/host.c b/thirdparty/enet/host.c diff --git a/thirdparty/enet/host.c b/thirdparty/enet/host.c
index 3b2180f7fd..21ab27e247 100644 index fff946a392..adb3533cf1 100644
--- a/thirdparty/enet/host.c --- a/thirdparty/enet/host.c
+++ b/thirdparty/enet/host.c +++ b/thirdparty/enet/host.c
@@ -87,7 +87,7 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL @@ -87,7 +87,7 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL
@ -63,10 +63,10 @@ index 3b2180f7fd..21ab27e247 100644
host -> receivedData = NULL; host -> receivedData = NULL;
host -> receivedDataLength = 0; host -> receivedDataLength = 0;
diff --git a/thirdparty/enet/protocol.c b/thirdparty/enet/protocol.c diff --git a/thirdparty/enet/protocol.c b/thirdparty/enet/protocol.c
index 9d654f1d96..d7fe80f117 100644 index 843a719af3..5f18700599 100644
--- a/thirdparty/enet/protocol.c --- a/thirdparty/enet/protocol.c
+++ b/thirdparty/enet/protocol.c +++ b/thirdparty/enet/protocol.c
@@ -309,7 +309,7 @@ enet_protocol_handle_connect (ENetHost * host, ENetProtocolHeader * header, ENet @@ -318,7 +318,7 @@ enet_protocol_handle_connect (ENetHost * host, ENetProtocolHeader * header, ENet
} }
else else
if (currentPeer -> state != ENET_PEER_STATE_CONNECTING && if (currentPeer -> state != ENET_PEER_STATE_CONNECTING &&
@ -75,7 +75,7 @@ index 9d654f1d96..d7fe80f117 100644
{ {
if (currentPeer -> address.port == host -> receivedAddress.port && if (currentPeer -> address.port == host -> receivedAddress.port &&
currentPeer -> connectID == command -> connect.connectID) currentPeer -> connectID == command -> connect.connectID)
@@ -1031,9 +1031,8 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event) @@ -1043,9 +1043,8 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event)
if (peer -> state == ENET_PEER_STATE_DISCONNECTED || if (peer -> state == ENET_PEER_STATE_DISCONNECTED ||
peer -> state == ENET_PEER_STATE_ZOMBIE || peer -> state == ENET_PEER_STATE_ZOMBIE ||
@ -87,7 +87,7 @@ index 9d654f1d96..d7fe80f117 100644
(peer -> outgoingPeerID < ENET_PROTOCOL_MAXIMUM_PEER_ID && (peer -> outgoingPeerID < ENET_PROTOCOL_MAXIMUM_PEER_ID &&
sessionID != peer -> incomingSessionID)) sessionID != peer -> incomingSessionID))
return 0; return 0;
@@ -1075,7 +1074,7 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event) @@ -1090,7 +1089,7 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event)
if (peer != NULL) if (peer != NULL)
{ {

View File

@ -1071,11 +1071,14 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event)
if (host -> checksum != NULL) if (host -> checksum != NULL)
{ {
enet_uint32 * checksum = (enet_uint32 *) & host -> receivedData [headerSize - sizeof (enet_uint32)], enet_uint32 * checksum = (enet_uint32 *) & host -> receivedData [headerSize - sizeof (enet_uint32)];
desiredChecksum = * checksum; enet_uint32 desiredChecksum, newChecksum;
ENetBuffer buffer; ENetBuffer buffer;
/* Checksum may be an unaligned pointer, use memcpy to avoid undefined behaviour. */
memcpy (& desiredChecksum, checksum, sizeof (enet_uint32));
* checksum = peer != NULL ? peer -> connectID : 0; newChecksum = peer != NULL ? peer -> connectID : 0;
memcpy (checksum, & newChecksum, sizeof (enet_uint32));
buffer.data = host -> receivedData; buffer.data = host -> receivedData;
buffer.dataLength = host -> receivedDataLength; buffer.dataLength = host -> receivedDataLength;
@ -1703,9 +1706,12 @@ enet_protocol_send_outgoing_commands (ENetHost * host, ENetEvent * event, int ch
if (host -> checksum != NULL) if (host -> checksum != NULL)
{ {
enet_uint32 * checksum = (enet_uint32 *) & headerData [host -> buffers -> dataLength]; enet_uint32 * checksum = (enet_uint32 *) & headerData [host -> buffers -> dataLength];
* checksum = currentPeer -> outgoingPeerID < ENET_PROTOCOL_MAXIMUM_PEER_ID ? currentPeer -> connectID : 0; enet_uint32 newChecksum = currentPeer -> outgoingPeerID < ENET_PROTOCOL_MAXIMUM_PEER_ID ? currentPeer -> connectID : 0;
/* Checksum may be unaligned, use memcpy to avoid undefined behaviour. */
memcpy(checksum, & newChecksum, sizeof (enet_uint32));
host -> buffers -> dataLength += sizeof (enet_uint32); host -> buffers -> dataLength += sizeof (enet_uint32);
* checksum = host -> checksum (host -> buffers, host -> bufferCount); newChecksum = host -> checksum (host -> buffers, host -> bufferCount);
memcpy(checksum, & newChecksum, sizeof (enet_uint32));
} }
if (shouldCompress > 0) if (shouldCompress > 0)