Repository: mesos
Updated Branches:
  refs/heads/master 1cbfdc3c1 -> aa17a6572


Added negative number validation for 'files/read' offset parameter.

In this patch:
\- Added negative number validation for 'files/read' offset parameter
in files.cpp. Previously, it used to fail with a 'InternalServerError'.
\- Corrected the indent of negative number check response for
length parameter in files.cpp.

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


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

Branch: refs/heads/master
Commit: da674fc56bdf3a75c8d7d13a8bf214a743e1360d
Parents: 1cbfdc3
Author: zhou xing <xingz...@cn.ibm.com>
Authored: Fri Jul 8 21:33:51 2016 -0700
Committer: Anand Mazumdar <an...@apache.org>
Committed: Fri Jul 8 21:33:51 2016 -0700

----------------------------------------------------------------------
 src/files/files.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/da674fc5/src/files/files.cpp
----------------------------------------------------------------------
diff --git a/src/files/files.cpp b/src/files/files.cpp
index c8991c4..4b12f93 100644
--- a/src/files/files.cpp
+++ b/src/files/files.cpp
@@ -508,6 +508,11 @@ Future<http::Response> FilesProcess::read(
       return BadRequest("Failed to parse offset: " + result.error() + ".\n");
     }
 
+    if (result.get() < -1) {
+      return BadRequest(strings::format(
+          "Negative offset provided: %d.\n", result.get()).get());
+    }
+
     offset = result.get();
   }
 
@@ -527,8 +532,8 @@ Future<http::Response> FilesProcess::read(
     // read to the end of the file, up to the maximum read length.
     // Will change this logic in MESOS-5334.
     if (result.get() < -1) {
-      return BadRequest(
-        strings::format("Negative length provided: %d.\n", 
result.get()).get());
+      return BadRequest(strings::format(
+          "Negative length provided: %d.\n", result.get()).get());
     }
 
     if (result.get() > -1){

Reply via email to