From bb8526ac28bc87223f76ac8ec341f19c00208328 Mon Sep 17 00:00:00 2001 From: Moreal Date: Sat, 13 Aug 2022 02:25:36 +0900 Subject: [PATCH] Raise ValueError if null character exists for eval argument --- vm/src/stdlib/builtins.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vm/src/stdlib/builtins.rs b/vm/src/stdlib/builtins.rs index 4d11faf27..4c5579695 100644 --- a/vm/src/stdlib/builtins.rs +++ b/vm/src/stdlib/builtins.rs @@ -259,6 +259,11 @@ mod builtins { Either::A(ref a) => a.as_str().as_bytes(), Either::B(ref b) => b.as_bytes(), }; + for x in source { + if *x == 0 { + return Err(vm.new_value_error("source code string cannot contain null bytes".to_owned())); + } + } Ok(Either::A(vm.ctx.new_str(std::str::from_utf8(source).unwrap()))) },