diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2019-10-25 19:23:16 +0200 |
---|---|---|
committer | Ry Dahl <ry@tinyclouds.org> | 2019-10-25 13:23:16 -0400 |
commit | dfcdc0315233019740d76448be68cad0292a6c1d (patch) | |
tree | 68be63c092cdfe1d8ac9bcf04c5cfe3a05e4f691 /cli/ops/dispatch_minimal.rs | |
parent | 2270abbc448c31c958d78ec55714392f77c13472 (diff) |
fix: handle malformed control buffers (#3202)
Diffstat (limited to 'cli/ops/dispatch_minimal.rs')
-rw-r--r-- | cli/ops/dispatch_minimal.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/cli/ops/dispatch_minimal.rs b/cli/ops/dispatch_minimal.rs index 6170890a3..c19521bf1 100644 --- a/cli/ops/dispatch_minimal.rs +++ b/cli/ops/dispatch_minimal.rs @@ -5,6 +5,7 @@ //! messages. The first i32 is used to determine if a message a flatbuffer //! message or a "minimal" message. use crate::deno_error::GetErrorKind; +use crate::msg::ErrorKind; use byteorder::{LittleEndian, WriteBytesExt}; use deno::Buf; use deno::CoreOp; @@ -115,7 +116,21 @@ pub fn minimal_op( d: Dispatcher, ) -> impl Fn(&[u8], Option<PinnedBuf>) -> CoreOp { move |control: &[u8], zero_copy: Option<PinnedBuf>| { - let mut record = parse_min_record(control).unwrap(); + let mut record = match parse_min_record(control) { + Some(r) => r, + None => { + let error_record = ErrorRecord { + promise_id: 0, + arg: -1, + error_code: ErrorKind::InvalidInput as i32, + error_message: "Unparsable control buffer" + .to_string() + .as_bytes() + .to_owned(), + }; + return Op::Sync(error_record.into()); + } + }; let is_sync = record.promise_id == 0; let rid = record.arg; let min_op = d(rid, zero_copy); |