Skip to content

Commit

Permalink
all: Fixed incorrect dereference introduced with ccdc34a.
Browse files Browse the repository at this point in the history
  • Loading branch information
levy committed Oct 14, 2024
1 parent 52055c8 commit 42f8944
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/inet/networklayer/ipv4/Ipv4HeaderSerializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const Ptr<Chunk> Ipv4HeaderSerializer::deserialize(MemoryInputStream& stream) co
uint8_t *buffer = new uint8_t[B(IPv4_MIN_HEADER_LENGTH).get()];
stream.readBytes(buffer, IPv4_MIN_HEADER_LENGTH);
auto ipv4Header = makeShared<Ipv4Header>();
const struct ip& iphdr = *static_cast<const struct ip *>((void *)&buffer);
const struct ip& iphdr = *static_cast<const struct ip *>((void *)buffer);
B totalLength, headerLength;

ipv4Header->setVersion(iphdr.ip_v);
Expand Down
6 changes: 3 additions & 3 deletions src/inet/transportlayer/sctp/SctpAssociationUtil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1449,8 +1449,8 @@ static uint32_t compressGaps(const SctpGapList *gapList, const SctpGapList::GapT
const uint16_t startOffset = gapList->getGapStart(type, i) - last;
const uint16_t stopOffset = gapList->getGapStop(type, i) - gapList->getGapStart(type, i);
const size_t lastOutputPos = outputPos;
if ((writeCompressedValue((uint8_t *)&compressedDataBuffer, compressedDataBufferSize, outputPos, startOffset) == false) ||
(writeCompressedValue((uint8_t *)&compressedDataBuffer, compressedDataBufferSize, outputPos, stopOffset) == false) ||
if ((writeCompressedValue(compressedDataBuffer, compressedDataBufferSize, outputPos, startOffset) == false) ||
(writeCompressedValue(compressedDataBuffer, compressedDataBufferSize, outputPos, stopOffset) == false) ||
(outputPos + 1 > space))
{
outputPos = lastOutputPos;
Expand All @@ -1459,7 +1459,7 @@ static uint32_t compressGaps(const SctpGapList *gapList, const SctpGapList::GapT
entriesWritten++;
last = gapList->getGapStop(type, i);
}
ASSERT(writeCompressedValue((uint8_t *)&compressedDataBuffer, compressedDataBufferSize, outputPos, 0x00) == true);
ASSERT(writeCompressedValue(compressedDataBuffer, compressedDataBufferSize, outputPos, 0x00) == true);
space = outputPos;

delete [] compressedDataBuffer;
Expand Down
2 changes: 1 addition & 1 deletion src/inet/transportlayer/sctp/SctpHeaderSerializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ const Ptr<Chunk> SctpHeaderSerializer::deserialize(MemoryInputStream& stream) co
stream.readBytes(buffer, B(bufsize));
auto dest = makeShared<SctpHeader>();

struct common_header *common_header = (struct common_header *)((void *)&buffer);
struct common_header *common_header = (struct common_header *)((void *)buffer);
int32_t tempChecksum = common_header->checksum;
common_header->checksum = 0;
int32_t chksum = SctpChecksum::checksum((unsigned char *)common_header, bufsize);
Expand Down
2 changes: 1 addition & 1 deletion src/inet/transportlayer/tcp_common/TcpHeaderSerializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const Ptr<Chunk> TcpHeaderSerializer::deserialize(MemoryInputStream& stream) con
uint8_t *buffer = new uint8_t[B(TCP_MIN_HEADER_LENGTH).get()];
stream.readBytes(buffer, TCP_MIN_HEADER_LENGTH);
auto tcpHeader = makeShared<TcpHeader>();
const struct tcphdr& tcp = *static_cast<const struct tcphdr *>((void *)&buffer);
const struct tcphdr& tcp = *static_cast<const struct tcphdr *>((void *)buffer);
ASSERT(B(sizeof(tcp)) == TCP_MIN_HEADER_LENGTH);

// fill Tcp header structure
Expand Down

0 comments on commit 42f8944

Please sign in to comment.