Skip to content

Commit

Permalink
Merge pull request H-uru#1500 from dgelessus/plnetaddress_endianness_…
Browse files Browse the repository at this point in the history
…fixes

Fix a couple of endianness issues with `plNetAddress`
  • Loading branch information
Hoikas authored Oct 13, 2023
2 parents 0cfbcb8 + 30bcfa2 commit 74a5374
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Sources/Plasma/NucleusLib/pnNetCommon/plNetAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ ST::string plNetAddress::AsString() const

void plNetAddress::Read(hsStream * s)
{
fHost = s->ReadLE32();
// No endianness conversion here - fHost is always big-endian in memory and in the stream!
s->Read(sizeof(fHost), &fHost);
fPort = s->ReadLE16();

// Family is always kInet
Expand All @@ -97,7 +98,8 @@ void plNetAddress::Read(hsStream * s)

void plNetAddress::Write(hsStream * s)
{
s->WriteLE32(fHost);
// No endianness conversion here - fHost is always big-endian in memory and in the stream!
s->Write(sizeof(fHost), &fHost);
s->WriteLE16(fPort);

s->WriteLE16(static_cast<uint16_t>(Family::kInet));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1861,7 +1861,7 @@ bool RecvMsg<Auth2Cli_ServerAddr>(const uint8_t in[], unsigned, void*)
hsLockGuard(s_critsect);
if (s_active) {
s_active->token = msg.token;
s_active->addr.SetHost(msg.srvAddr);
s_active->addr.SetHost(hsToBE32(msg.srvAddr));

LogMsg(kLogPerf, "SrvAuth addr: {}", s_active->addr.GetHostString());
}
Expand Down

0 comments on commit 74a5374

Please sign in to comment.