Repository: mesos Updated Branches: refs/heads/master e370b0997 -> c229d1b83
Prevent agent from crashing when the ID is too long. When launching a task with a very long name mkdir will fail and crash the agent, making it quick and easy to remotely crash any agent(s). This changes makes sure that we never exceed the default file name limit of most of the file systems out there. If the limit is exceed a TASK_ERROR is instead sent back to the client. Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/c229d1b8 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/c229d1b8 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/c229d1b8 Branch: refs/heads/master Commit: c229d1b837edde0fc4b2826514cbb11a1261d39d Parents: e370b09 Author: Aaron Wood <[email protected]> Authored: Sun Apr 16 15:21:09 2017 +0800 Committer: Jie Yu <[email protected]> Committed: Sun Apr 16 15:21:09 2017 +0800 ---------------------------------------------------------------------- src/common/validation.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/c229d1b8/src/common/validation.cpp ---------------------------------------------------------------------- diff --git a/src/common/validation.cpp b/src/common/validation.cpp index 544d3a0..33b501b 100644 --- a/src/common/validation.cpp +++ b/src/common/validation.cpp @@ -16,10 +16,13 @@ #include "common/validation.hpp" +#include <limits.h> + #include <algorithm> #include <cctype> #include <stout/foreach.hpp> +#include <stout/stringify.hpp> #include <stout/unreachable.hpp> #include <stout/os/constants.hpp> @@ -37,13 +40,19 @@ Option<Error> validateID(const string& id) return Error("ID must not be empty"); } + if (id.length() > NAME_MAX) { + return Error( + "ID must not be greater than " + + stringify(NAME_MAX) + " characters"); + } + // The ID cannot be exactly these special path components. if (id == "." || id == "..") { return Error("'" + id + "' is disallowed"); } // Rules on invalid characters in the ID: - // - Control charaters are obviously not allowed. + // - Control characters are obviously not allowed. // - Slashes are disallowed as IDs are likely mapped to directories in Mesos. auto invalidCharacter = [](char c) { return iscntrl(c) ||
