Skip to content

Commit 10822d4

Browse files
committed
Propagate bitvector analysis state across function calls
1 parent 5d84b1f commit 10822d4

File tree

5 files changed

+79
-0
lines changed

5 files changed

+79
-0
lines changed
Binary file not shown.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class interproc1
2+
{
3+
static void my_method()
4+
{
5+
Object o=null;
6+
7+
my_f(o); // T1 source
8+
my_g(o);
9+
}
10+
11+
static void my_g(Object p)
12+
{
13+
my_h(p); // T1 sink
14+
}
15+
16+
static void my_f(Object p) { }
17+
static void my_h(Object p) { }
18+
};
19+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[
2+
{ "id": "my_f", "kind": "source", "where": "parameter1", "taint": "T1", "function": "interproc1.my_f" },
3+
{ "id": "my_h1", "kind": "sink", "where": "parameter1", "taint": "T1", "function": "interproc1.my_h", "message": "There is a T1 flow" }
4+
]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
interproc1.class
3+
--taint taint.json
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^file interproc1.java line 13( function .*)?: There is a T1 flow \(taint rule my_h1\)$
7+
--
8+
^warning: ignoring

src/analyses/custom_bitvector_analysis.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,54 @@ void custom_bitvector_domaint::transform(
334334
}
335335
}
336336
}
337+
else
338+
{
339+
goto_programt::const_targett next=from;
340+
++next;
341+
342+
// only if there is an actual call, i.e., we have a body
343+
if(next!=to)
344+
{
345+
const code_typet &code_type=
346+
to_code_type(ns.lookup(identifier).type);
347+
348+
code_function_callt::argumentst::const_iterator arg_it=
349+
code_function_call.arguments().begin();
350+
for(const auto &param : code_type.parameters())
351+
{
352+
const irep_idt &p_identifier=param.get_identifier();
353+
if(p_identifier.empty())
354+
continue;
355+
356+
// there may be a mismatch in the number of arguments
357+
if(arg_it==code_function_call.arguments().end())
358+
break;
359+
360+
// assignments arguments -> parameters
361+
symbol_exprt p=ns.lookup(p_identifier).symbol_expr();
362+
// may alias other stuff
363+
std::set<exprt> lhs_set=cba.aliases(p, from);
364+
365+
vectorst rhs_vectors=get_rhs(*arg_it);
366+
367+
for(const auto &lhs : lhs_set)
368+
{
369+
assign_lhs(lhs, rhs_vectors);
370+
}
371+
372+
// is it a pointer?
373+
if(p.type().id()==ID_pointer)
374+
{
375+
dereference_exprt lhs_deref(p);
376+
dereference_exprt rhs_deref(*arg_it);
377+
vectorst rhs_vectors=get_rhs(rhs_deref);
378+
assign_lhs(lhs_deref, rhs_vectors);
379+
}
380+
381+
++arg_it;
382+
}
383+
}
384+
}
337385
}
338386
}
339387
break;

0 commit comments

Comments
 (0)