Changeset - r25652:89ab1173802a
[Not reviewed]
master
0 1 0
rubidium42 - 3 years ago 2021-06-13 08:07:44
rubidium@openttd.org
Fix #9361, a2051ba: [Network] Off by one in CanWriteToPacket

Previously it did not allow writing a byte to a packet that was of size limit - 1 anymore.
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/network/core/packet.cpp
Show inline comments
 
@@ -95,13 +95,13 @@ void Packet::PrepareToSend()
 
 * Is it safe to write to the packet, i.e. didn't we run over the buffer?
 
 * @param bytes_to_write The amount of bytes we want to try to write.
 
 * @return True iff the given amount of bytes can be written to the packet.
 
 */
 
bool Packet::CanWriteToPacket(size_t bytes_to_write)
 
{
 
	return this->Size() + bytes_to_write < this->limit;
 
	return this->Size() + bytes_to_write <= this->limit;
 
}
 

	
 
/*
 
 * The next couple of functions make sure we can send
 
 *  uint8, uint16, uint32 and uint64 endian-safe
 
 *  over the network. The least significant bytes are
0 comments (0 inline, 0 general)