Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Add upper limit for file size transfers (CVSS score: 4.0) #129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Source/FileListTransfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,10 @@ void FileListTransfer::OnReferencePush(Packet *packet, bool isTheFullFile)
FLR_MemoryBlock mb;
if (fileListReceiver->pushedFiles.Has(onFileStruct.fileIndex)==false)
{
mb.flrMemoryBlock=(char*) rakMalloc_Ex(onFileStruct.byteLengthOfThisFile, _FILE_AND_LINE_);
if (onFileStruct.byteLengthOfThisFile <= RAKNET_MAX_RETRIEVABLE_FILESIZE)
mb.flrMemoryBlock=(char*) rakMalloc_Ex(onFileStruct.byteLengthOfThisFile, _FILE_AND_LINE_);
else
mb.flrMemoryBlock = nullptr;
fileListReceiver->pushedFiles.SetNew(onFileStruct.fileIndex, mb);
}
else
Expand Down
8 changes: 8 additions & 0 deletions Source/RakNetDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,12 @@

//#define USE_THREADED_SEND

// Controls the maximum retrievable filesize for incoming files using FileListTransfer.
// The configured limit only applies for files which are transferred incrementally (which basically applies to any larger file).
// Note that this also impacts the upper limit for memory allocations. It's suggested to redefine the value to a reasonable smaller size in the RakNetDefineOverrides.h header file.
// For backwards compatibility with RakNet, the default is set to 4 GiB-1.
#ifndef RAKNET_MAX_RETRIEVABLE_FILESIZE
#define RAKNET_MAX_RETRIEVABLE_FILESIZE (0xFFFFFFFF)
#endif

#endif // __RAKNET_DEFINES_H