mesos-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joseph Wu <>
Subject Re: Review Request 56906: Dealt with a corner case in the ReadFile API.
Date Tue, 28 Feb 2017 00:46:35 GMT

This is an automatically generated e-mail. To reply, visit:

(Updated Feb. 27, 2017, 4:46 p.m.)

Review request for mesos and Anand Mazumdar.


Changed to a less-invasive approach, of just changing one continuation of the `FilesProcess`
with some extra validation logic.  This results in a much smaller patch overall, and less

Summary (updated)

Dealt with a corner case in the ReadFile API.

Repository: mesos


The canonical integer type used when dealing with files in Posix
is an `off_t`, or a signed 64-bit integer.  In our `FilesProcess`,
we actually use a `size_t`, an unsigned 64-bit integer, to represent
file offsets and lengths.  This opens up the potential for passing in
negative values (in 2's complement, an unsigned value greater than
2^63 - 1 becomes a negative value when casted to a signed value) 
for the offset and length.

In the current code, this leads to a discrepancy in return values
when a caller uses the `/files/read` endpoint versus the `ReadFile`

Calling `/files/read?offset=9223372036854775808` (2^63) will return a
`400 Bad Request`.  Performing the equivalent call via `ReadFile`
will instead return a `200 OK`, with no data actually read.

Diffs (updated)

  src/files/files.cpp 8327f8002fbfa3be77a4bbe4aa83a73d0f170f7a 
  src/tests/api_tests.cpp 24f31ff133185a3224f9edaf8b8532d5630b34c2 
  src/tests/files_tests.cpp 6c6353e406249f021803e83909415e9908ded28c 


Testing (updated)

make check

src/mesos-tests --gtest_filter="*FilesTest*:*MasterAPITest*"


Joseph Wu

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message