summaryrefslogtreecommitdiffstats
path: root/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2016-02-16 13:53:59 +0200
committerHanoh Haim <hhaim@cisco.com>2016-02-16 13:53:59 +0200
commit75c84998813a359cb8619e80507e04f21d71de89 (patch)
tree3c267650a51c075778318aecab914bc9134866cc /src/rpc-server/commands/trex_rpc_cmd_stream.cpp
parent8f6067d8738fa77a147955ee208ece8dea198111 (diff)
add sanity check for flow_var instruction
Diffstat (limited to 'src/rpc-server/commands/trex_rpc_cmd_stream.cpp')
-rw-r--r--src/rpc-server/commands/trex_rpc_cmd_stream.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
index 8d813b7b..0262fd7c 100644
--- a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
+++ b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
@@ -250,6 +250,37 @@ TrexRpcCmdAddStream::parse_vm_instr_flow_var(const Json::Value &inst, TrexStream
uint64_t min_value = parse_uint64(inst, "min_value", result);
uint64_t max_value = parse_uint64(inst, "max_value", result);
+ if (max_value < min_value ) {
+ std::stringstream ss;
+ ss << "VM: request flow var variable '" << max_value << "' is smaller than " << min_value;
+ generate_parse_err(result, ss.str());
+ }
+
+ if (flow_var_size == 1 ) {
+ if ( (init_value > UINT8_MAX) || (min_value > UINT8_MAX) || (max_value > UINT8_MAX)) {
+ std::stringstream ss;
+ ss << "VM: request val is bigger than " << UINT8_MAX;
+ generate_parse_err(result, ss.str());
+ }
+ }
+
+ if (flow_var_size == 2 ) {
+ if ( (init_value > UINT16_MAX) || (min_value > UINT16_MAX) || (max_value > UINT16_MAX)) {
+ std::stringstream ss;
+ ss << "VM: request val is bigger than " << UINT16_MAX;
+ generate_parse_err(result, ss.str());
+ }
+ }
+
+ if (flow_var_size == 4 ) {
+ if ( (init_value > UINT32_MAX) || (min_value > UINT32_MAX) || (max_value > UINT32_MAX)) {
+ std::stringstream ss;
+ ss << "VM: request val is bigger than " << UINT32_MAX;
+ generate_parse_err(result, ss.str());
+ }
+ }
+
+
stream->m_vm.add_instruction(new StreamVmInstructionFlowMan(flow_var_name,
flow_var_size,
op_type,