1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-02 16:57:47 +00:00

Tempoary bound check for GamePacket

This commit is contained in:
Adam 2017-08-26 15:07:31 +09:00
parent 5fedd0c1df
commit 4ecc5cef54

View file

@ -38,27 +38,32 @@ public:
template<class T> template<class T>
void setValAt( uint16_t pos, T value ) void setValAt( uint16_t pos, T value )
{ {
assert( m_segHdr.size > pos );
memcpy( reinterpret_cast< uint8_t* >( &m_dataBuf[0] + pos ), &value, sizeof( T ) ); memcpy( reinterpret_cast< uint8_t* >( &m_dataBuf[0] + pos ), &value, sizeof( T ) );
} }
template<class T> template<class T>
T getValAt( uint16_t pos ) const T getValAt( uint16_t pos ) const
{ {
assert(m_segHdr.size > pos);
return *reinterpret_cast< const T* >( &m_dataBuf[0] + pos ); return *reinterpret_cast< const T* >( &m_dataBuf[0] + pos );
} }
void setBytesAt( uint16_t offset, uint8_t * bytes, uint16_t length ) void setBytesAt( uint16_t offset, uint8_t * bytes, uint16_t length )
{ {
assert(m_segHdr.size > offset);
memcpy( reinterpret_cast< uint8_t* >( &m_dataBuf[0] + offset ), bytes, length ); memcpy( reinterpret_cast< uint8_t* >( &m_dataBuf[0] + offset ), bytes, length );
} }
const char * getStringAt( uint16_t pos ) const const char * getStringAt( uint16_t pos ) const
{ {
assert(m_segHdr.size > pos);
return reinterpret_cast< const char* >( &m_dataBuf[0] + pos ); return reinterpret_cast< const char* >( &m_dataBuf[0] + pos );
} }
void setStringAt( uint16_t pos, const std::string& str ) void setStringAt( uint16_t pos, const std::string& str )
{ {
assert(m_segHdr.size > pos);
memcpy( reinterpret_cast< uint8_t* >( &m_dataBuf[0] + pos ), str.c_str(), str.length() ); memcpy( reinterpret_cast< uint8_t* >( &m_dataBuf[0] + pos ), str.c_str(), str.length() );
} }