Skip to content

Commit 114bcb4

Browse files
authored
Merge pull request diffblue#480 from diffblue/removal_of_nondet_ptr
SEC-517, SEC-509: Removal of 'var = NONDET(SomeType *);' assignments.
2 parents db4f688 + e5e2cc4 commit 114bcb4

File tree

3 files changed

+23
-33
lines changed

3 files changed

+23
-33
lines changed

src/driver/sec_driver_parse_options.cpp

+7-28
Original file line numberDiff line numberDiff line change
@@ -512,29 +512,8 @@ void sec_driver_parse_optionst::process_goto_function(
512512

513513
replace_java_nondet(function);
514514

515-
#if 0 // Enable this when remove handling of NONDET in taint_analysis
516-
// Similar removal of java nondet statements:
517-
// TODO Should really get this from java_bytecode_language somehow, but we
518-
// don't have an instance of that here.
519-
object_factory_parameterst factory_params;
520-
factory_params.max_nondet_array_length=
521-
cmdline.isset("java-max-input-array-length")
522-
? std::stoul(cmdline.get_value("java-max-input-array-length"))
523-
: MAX_NONDET_ARRAY_LENGTH_DEFAULT;
524-
factory_params.max_nondet_string_length=
525-
cmdline.isset("string-max-input-length")
526-
? std::stoul(cmdline.get_value("string-max-input-length"))
527-
: MAX_NONDET_STRING_LENGTH;
528-
factory_params.max_nondet_tree_depth=
529-
cmdline.isset("java-max-input-tree-depth")
530-
? std::stoul(cmdline.get_value("java-max-input-tree-depth"))
531-
: MAX_NONDET_TREE_DEPTH;
532-
533515
convert_nondet(
534-
function,
535-
get_message_handler(),
536-
factory_params);
537-
#endif
516+
function, get_message_handler(), object_factory_params, ID_java);
538517

539518
adjust_float_expressions(goto_function, namespacet(symbol_table));
540519

@@ -657,12 +636,12 @@ bool sec_driver_parse_optionst::generate_function_body(
657636
{
658637
// Provide a simple stub implementation for any function we don't have a
659638
// bytecode implementation for:
660-
661-
if(body_available)
662-
return false;
663-
664-
if(!can_generate_function_body(function_name))
665-
return false;
639+
if(body_available || !can_generate_function_body(function_name))
640+
{
641+
const symbolt *symbol = symbol_table.lookup(function_name);
642+
if(symbol == nullptr || !symbol->type.get_bool(ID_C_abstract))
643+
return false;
644+
}
666645

667646
if(symbol_table.lookup_ref(function_name).mode == ID_java)
668647
{

src/taint-analysis/taint_program.h

-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@
2121

2222
typedef goto_programt::instructiont::const_targett instruction_iteratort;
2323

24-
typedef std::unordered_map<
25-
instruction_iteratort,
26-
symbol_exprt,
27-
instruction_iterator_hashert> replacements_of_NONDET_retvalst;
28-
2924
class taint_statisticst;
3025

3126

src/taint-slicer/slicing_tasks_builder.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,22 @@ std::pair<taint_slicing_taskt,std::string> build_slicing_task(
326326
I.function=fname_prog.first;
327327
}
328328

329+
// Check that the goto program to be saved does not contain any NONDET(T*)
330+
// expressions. However, non-pointer NONDET expressions can be present.
331+
class nondet_visitort : public const_expr_visitort
332+
{
333+
public:
334+
void operator()(const exprt &expr) override
335+
{
336+
INVARIANT(
337+
expr.id() != ID_nondet || expr.type().id() != ID_pointer,
338+
"No pointer-typed NONDET allowed.");
339+
}
340+
} visitor;
341+
for(auto &fname_prog : goto_functions.function_map)
342+
for(const auto &I : fname_prog.second.body.instructions)
343+
I.code.visit(visitor);
344+
329345
// Finally save the constructed slicing task on the disc as GOTO program
330346
// binary.
331347
const bool fail=write_goto_binary(

0 commit comments

Comments
 (0)