Skip to content

Commit aa76fbd

Browse files
committed
Forbid bad map names in map commands
This fixes the part of Unvanquished/Unvanquished#3080 where the server drops (the map command is ignored instead).
1 parent fb539cf commit aa76fbd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/engine/server/sv_ccmds.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class MapCmd: public Cmd::StaticCmd {
5151
}
5252

5353
void Run(const Cmd::Args& args) const override {
54-
if (args.Argc() < 2) {
54+
if (args.Argc() < 2 || args.Argv(1).empty()) {
5555
PrintUsage(args, "<mapname> (layoutname)", "loads a new map");
5656
return;
5757
}
@@ -64,6 +64,12 @@ class MapCmd: public Cmd::StaticCmd {
6464
}
6565

6666
const std::string& mapName = args.Argv(1);
67+
68+
if (mapName.find_first_of("/\\") != mapName.npos) {
69+
Print("Map name '%s' must not contain directory separators", mapName);
70+
return;
71+
}
72+
6773
// For non-legacy paks, a map named "foo" must be in the pak "map-foo"
6874
std::string pakName;
6975

0 commit comments

Comments
 (0)