Repository: mesos
Updated Branches:
  refs/heads/1.2.x d9e6daa11 -> 8d847ec01


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.

Review: https://reviews.apache.org/r/58317/

*** Modified for 1.2.x. ***


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/60008141
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/60008141
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/60008141

Branch: refs/heads/1.2.x
Commit: 60008141eda4c1f4a3b556040977473657c030f9
Parents: d9e6daa
Author: Aaron Wood <[email protected]>
Authored: Sun Apr 16 15:21:09 2017 +0800
Committer: Jie Yu <[email protected]>
Committed: Thu Apr 20 07:31:59 2017 +0800

----------------------------------------------------------------------
 src/common/validation.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/60008141/src/common/validation.cpp
----------------------------------------------------------------------
diff --git a/src/common/validation.cpp b/src/common/validation.cpp
index 0f1a022..4a2ff98 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/os/constants.hpp>
 
@@ -45,6 +48,12 @@ Option<Error> validateID(const string& id)
     return Error("ID must be non-empty");
   }
 
+  if (id.length() > NAME_MAX) {
+    return Error(
+        "ID must not be greater than " +
+        stringify(NAME_MAX) + " characters");
+  }
+
   if (std::any_of(id.begin(), id.end(), invalidCharacter)) {
     return Error("'" + id + "' contains invalid characters");
   }

Reply via email to