Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Guard against overflow when peeking at PDU size
This is a partial cherry-pick from my commit to the Facebook Watchman project[0]. I noticed while reviewing the corresponding pull request[1] that a malformed header could cause us to index beyond the range of the `sizes` array, so this commit pulls in the equivalent guard. Note there is a bunch of other stuff in that pull-request and that specific commit which I am not pulling down here. That code is in a gem and so needs to be more defensive; in Command-T itself, if something goes wrong with Watchman we want to fail noisily and loudly. So we're not going to worry about freeing memory before throwing an exception (effectively crashing) nor do we care about restoring the flags to their pre-`fcntl` state (as we're the only users of the socket). [0]: facebook/watchman@5b0aa521ae [1]: facebook/watchman#37 [2]: facebook/watchman#37 (comment) Signed-off-by: Greg Hurrell <greg@hurrell.net>
- Loading branch information