Skip to content

Commit

Permalink
wip: explicitly check allowed mode values for plugin/test_input engines
Browse files Browse the repository at this point in the history
Signed-off-by: Grzegorz Nosek <[email protected]>
  • Loading branch information
gnosek committed Oct 17, 2023
1 parent b389434 commit aeda51d
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions userspace/libsinsp/sinsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,14 +719,16 @@ void sinsp::open_plugin(const std::string& plugin_name, const std::string& plugi
oargs.engine_params = &params;

struct scap_platform* platform;
if(mode == SCAP_MODE_PLUGIN)
switch(mode)
{
platform = scap_generic_alloc_platform(::on_new_entry_from_proc, this);
}
else
{
platform = scap_linux_alloc_platform(::on_new_entry_from_proc, this);

case SCAP_MODE_PLUGIN:
platform = scap_generic_alloc_platform(::on_new_entry_from_proc, this);
break;
case SCAP_MODE_LIVE:
platform = scap_linux_alloc_platform(::on_new_entry_from_proc, this);
break;
default:
throw sinsp_exception("Unsupported mode for SOURCE_PLUGIN engine");
}
open_common(&oargs, &scap_source_plugin_engine, platform);
#else
Expand Down Expand Up @@ -791,14 +793,16 @@ void sinsp::open_test_input(scap_test_input_data* data, scap_mode_t mode)
oargs.engine_params = &params;

struct scap_platform* platform;
if(mode == SCAP_MODE_TEST)
{
platform = scap_test_input_alloc_platform(::on_new_entry_from_proc, this);
}
else
switch(mode)
{
case SCAP_MODE_TEST:
platform = scap_generic_alloc_platform(::on_new_entry_from_proc, this);
break;
case SCAP_MODE_LIVE:
platform = scap_linux_alloc_platform(::on_new_entry_from_proc, this);

break;
default:
throw sinsp_exception("Unsupported mode for SOURCE_PLUGIN engine");
}
open_common(&oargs, &scap_test_input_engine, platform);

Expand Down

0 comments on commit aeda51d

Please sign in to comment.