diff --git a/Fw/FilePacket/PathName.cpp b/Fw/FilePacket/PathName.cpp index c66ee9233d4..68faa656b33 100644 --- a/Fw/FilePacket/PathName.cpp +++ b/Fw/FilePacket/PathName.cpp @@ -44,7 +44,7 @@ namespace Fw { { const U8* addrLeft = serialBuffer.getBuffAddrLeft(); - U8 bytes[this->length]; + U8 bytes[MAX_LENGTH]; const SerializeStatus status = serialBuffer.popBytes(bytes, this->length); if (status != FW_SERIALIZE_OK) diff --git a/Svc/BufferLogger/BufferLoggerFile.cpp b/Svc/BufferLogger/BufferLoggerFile.cpp index d9da1518cee..f4ed5b765ab 100644 --- a/Svc/BufferLogger/BufferLoggerFile.cpp +++ b/Svc/BufferLogger/BufferLoggerFile.cpp @@ -181,15 +181,16 @@ namespace Svc { bool BufferLogger::File :: writeSize(const U32 size) { + FW_ASSERT(this->sizeOfSize <= sizeof(U32)); + U8 sizeBuffer[sizeof(U32)]; U32 sizeRegister = size; - U8 sizeBuffer[this->sizeOfSize]; for (U8 i = 0; i < this->sizeOfSize; ++i) { sizeBuffer[this->sizeOfSize - i - 1] = sizeRegister & 0xFF; sizeRegister >>= 8; } const bool status = this->writeBytes( sizeBuffer, - sizeof(sizeBuffer) + this->sizeOfSize ); return status; } diff --git a/Svc/FileDownlink/FileDownlink.cpp b/Svc/FileDownlink/FileDownlink.cpp index 22d3866bf26..87a03f8ec91 100644 --- a/Svc/FileDownlink/FileDownlink.cpp +++ b/Svc/FileDownlink/FileDownlink.cpp @@ -402,7 +402,7 @@ namespace Svc { FW_ASSERT(byteOffset < this->endOffset); const U32 maxDataSize = FILEDOWNLINK_INTERNAL_BUFFER_SIZE - Fw::FilePacket::DataPacket::HEADERSIZE; const U32 dataSize = (byteOffset + maxDataSize > this->endOffset) ? (this->endOffset - byteOffset) : maxDataSize; - U8 buffer[dataSize]; + U8 buffer[FILEDOWNLINK_INTERNAL_BUFFER_SIZE - Fw::FilePacket::DataPacket::HEADERSIZE]; //This will be last data packet sent if (dataSize + byteOffset == this->endOffset) { this->lastCompletedType = Fw::FilePacket::T_DATA; diff --git a/Svc/FileUplink/File.cpp b/Svc/FileUplink/File.cpp index 718e432ef1c..aa6bd10ef7c 100644 --- a/Svc/FileUplink/File.cpp +++ b/Svc/FileUplink/File.cpp @@ -1,4 +1,4 @@ -// ====================================================================== +// ====================================================================== // \title File.cpp // \author bocchino // \brief cpp file for FileUplink::File @@ -7,8 +7,8 @@ // Copyright 2009-2016, by the California Institute of Technology. // ALL RIGHTS RESERVED. United States Government Sponsorship // acknowledged. -// -// ====================================================================== +// +// ====================================================================== #include #include @@ -18,16 +18,12 @@ namespace Svc { Os::File::Status FileUplink::File :: open(const Fw::FilePacket::StartPacket& startPacket) { - const U32 length = startPacket.destinationPath.length; - char path[length + 1]; - memcpy(path, startPacket.destinationPath.value, length); - path[length] = 0; this->size = startPacket.fileSize; - Fw::LogStringArg logStringArg(path); + Fw::LogStringArg logStringArg(startPacket.destinationPath.value); this->name = logStringArg; CFDP::Checksum checksum; this->checksum = checksum; - return this->osFile.open(path, Os::File::OPEN_WRITE); + return this->osFile.open(startPacket.destinationPath.value, Os::File::OPEN_WRITE); } Os::File::Status FileUplink::File :: diff --git a/Svc/GroundInterface/GroundInterface.cpp b/Svc/GroundInterface/GroundInterface.cpp index f79ad5346e3..8305da07124 100644 --- a/Svc/GroundInterface/GroundInterface.cpp +++ b/Svc/GroundInterface/GroundInterface.cpp @@ -1,8 +1,8 @@ -// ====================================================================== +// ====================================================================== // \title GroundInterface.cpp // \author lestarch // \brief cpp file for GroundInterface component implementation class -// ====================================================================== +// ====================================================================== #include #include @@ -16,7 +16,7 @@ namespace Svc { const U32 GroundInterfaceComponentImpl::END_WORD = static_cast(0xcafecafe); // ---------------------------------------------------------------------- - // Construction, initialization, and destruction + // Construction, initialization, and destruction // ---------------------------------------------------------------------- GroundInterfaceComponentImpl :: @@ -33,7 +33,7 @@ namespace Svc { void GroundInterfaceComponentImpl :: init( const NATIVE_INT_TYPE instance - ) + ) { GroundInterfaceComponentBase::init(instance); } @@ -129,7 +129,7 @@ namespace Svc { //read packet descriptor in size agnostic way U8 packet_descriptor_size = sizeof(FwPacketDescriptorType); - U8 packet_type_bytes[packet_descriptor_size]; + U8 packet_type_bytes[sizeof(FwPacketDescriptorType)]; Fw::SerializeStatus stat = m_in_ring.peek(packet_type_bytes, packet_descriptor_size, HEADER_SIZE); //m_in_ring.peek(packet_type, HEADER_SIZE); // this way is only valid for 4byte packet descriptors if(stat == Fw::FW_SERIALIZE_OK)