mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-03 14:26:09 +00:00
fix out-of-range crash in SendFile
when the UnsafeName does not contain a `/`, the server would simply crash, as an invalid substr() index was given, which triggered a std::out_of_range.
This commit is contained in:
@@ -650,7 +650,14 @@ void TNetwork::Parse(TClient& c, const std::vector<uint8_t>& Packet) {
|
||||
}
|
||||
|
||||
void TNetwork::SendFile(TClient& c, const std::string& UnsafeName) {
|
||||
beammp_info(c.GetName() + " requesting : " + UnsafeName.substr(UnsafeName.find_last_of('/')));
|
||||
beammp_infof("{} ({}) requesting : '{}'", c.GetName(), c.GetID(), UnsafeName);
|
||||
|
||||
if (!fs::exists(UnsafeName)) {
|
||||
if (!TCPSend(c, StringToVector("CO"))) {
|
||||
// TODO: handle
|
||||
}
|
||||
beammp_warn("File '" + UnsafeName + "' does not exist!");
|
||||
}
|
||||
|
||||
if (!fs::path(UnsafeName).has_filename()) {
|
||||
if (!TCPSend(c, StringToVector("CO"))) {
|
||||
|
||||
Reference in New Issue
Block a user