Skip to content

Commit 84af116

Browse files
committed
Fix
1 parent 47eaebb commit 84af116

File tree

3 files changed

+26
-19
lines changed

3 files changed

+26
-19
lines changed

lib/Core/Executor.cpp

+17-10
Original file line numberDiff line numberDiff line change
@@ -5030,8 +5030,9 @@ void Executor::terminateStateOnTargetError(ExecutionState &state,
50305030
void Executor::terminateStateOnTargetTaintError(ExecutionState &state,
50315031
uint64_t hits, size_t sink) {
50325032
std::string error = "Taint error:";
5033-
const auto &sinkData = annotationsData.taintAnnotation.hits.at(sink);
5034-
for (size_t source = 0; source < annotationsData.taintAnnotation.sources.size(); source++) {
5033+
const auto &sinkData = annotationsData.taintAnnotation.hits[sink];
5034+
for (size_t source = 0;
5035+
source < annotationsData.taintAnnotation.sources.size(); source++) {
50355036
if ((hits >> source) & 1u) {
50365037
error += " " + annotationsData.taintAnnotation.rules[sinkData.at(source)];
50375038
}
@@ -5041,8 +5042,8 @@ void Executor::terminateStateOnTargetTaintError(ExecutionState &state,
50415042
state, ReachWithError(ReachWithErrorType::MaybeTaint, error));
50425043

50435044
terminateStateOnProgramError(
5044-
state, new ErrorEvent(locationOf(state), StateTerminationType::Taint,
5045-
error));
5045+
state,
5046+
new ErrorEvent(locationOf(state), StateTerminationType::Taint, error));
50465047
}
50475048

50485049
void Executor::terminateStateOnError(ExecutionState &state,
@@ -5550,6 +5551,8 @@ void Executor::executeChangeTaintSource(ExecutionState &state,
55505551
ref<PointerExpr> address,
55515552
uint64_t source, bool isAdd) {
55525553
address = optimizer.optimizeExpr(address, true);
5554+
ref<PointerExpr> base = PointerExpr::create(
5555+
address->getBase(), address->getBase(), address->getTaint());
55535556
ref<Expr> isNullPointer = Expr::createIsZero(address->getValue());
55545557
StatePair zeroPointer =
55555558
forkInternal(state, isNullPointer, BranchType::ResolvePointer);
@@ -5562,8 +5565,8 @@ void Executor::executeChangeTaintSource(ExecutionState &state,
55625565
}
55635566
if (zeroPointer.second) { // address != 0
55645567
ExactResolutionList rl;
5565-
resolveExact(*zeroPointer.second, address,
5566-
typeSystemManager->getUnknownType(), rl, "сhangeTaintSource");
5568+
resolveExact(*zeroPointer.second, base, typeSystemManager->getUnknownType(),
5569+
rl, "сhangeTaintSource");
55675570
for (Executor::ExactResolutionList::iterator it = rl.begin(), ie = rl.end();
55685571
it != ie; ++it) {
55695572
const MemoryObject *mo = it->first;
@@ -5589,6 +5592,8 @@ void Executor::executeCheckTaintSource(ExecutionState &state,
55895592
ref<PointerExpr> address,
55905593
uint64_t source) {
55915594
address = optimizer.optimizeExpr(address, true);
5595+
ref<PointerExpr> base = PointerExpr::create(
5596+
address->getBase(), address->getBase(), address->getTaint());
55925597
ref<Expr> isNullPointer = Expr::createIsZero(address->getValue());
55935598
StatePair zeroPointer =
55945599
forkInternal(state, isNullPointer, BranchType::ResolvePointer);
@@ -5601,8 +5606,8 @@ void Executor::executeCheckTaintSource(ExecutionState &state,
56015606
}
56025607
if (zeroPointer.second) {
56035608
ExactResolutionList rl;
5604-
resolveExact(*zeroPointer.second, address,
5605-
typeSystemManager->getUnknownType(), rl, "checkTaintSource");
5609+
resolveExact(*zeroPointer.second, base, typeSystemManager->getUnknownType(),
5610+
rl, "checkTaintSource");
56065611

56075612
for (Executor::ExactResolutionList::iterator it = rl.begin(), ie = rl.end();
56085613
it != ie; ++it) {
@@ -5629,6 +5634,8 @@ void Executor::executeGetTaintHits(ExecutionState &state,
56295634
}
56305635

56315636
address = optimizer.optimizeExpr(address, true);
5637+
ref<PointerExpr> base = PointerExpr::create(
5638+
address->getBase(), address->getBase(), address->getTaint());
56325639
ref<Expr> isNullPointer = Expr::createIsZero(address->getValue());
56335640
StatePair zeroPointer =
56345641
forkInternal(state, isNullPointer, BranchType::ResolvePointer);
@@ -5641,8 +5648,8 @@ void Executor::executeGetTaintHits(ExecutionState &state,
56415648
}
56425649
if (zeroPointer.second) {
56435650
ExactResolutionList rl;
5644-
resolveExact(*zeroPointer.second, address,
5645-
typeSystemManager->getUnknownType(), rl, "getTaintHits");
5651+
resolveExact(*zeroPointer.second, base, typeSystemManager->getUnknownType(),
5652+
rl, "getTaintHits");
56465653

56475654
for (Executor::ExactResolutionList::iterator it = rl.begin(), ie = rl.end();
56485655
it != ie; ++it) {

lib/Core/MockBuilder.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -684,10 +684,10 @@ void MockBuilder::buildAnnotationForExternalFunctionArgs(
684684
klee_error("Annotation: TaintOutput arg is not pointer");
685685
}
686686

687-
if (!isMocked) {
688-
buildCallKleeMakeMockAll(elem, mockName);
689-
isMocked = true;
690-
}
687+
// if (!isMocked) {
688+
// buildCallKleeMakeMockAll(elem, mockName);
689+
// isMocked = true;
690+
// }
691691
buildAnnotationTaintOutput(elem, statement);
692692
break;
693693
}
@@ -696,10 +696,10 @@ void MockBuilder::buildAnnotationForExternalFunctionArgs(
696696
klee_error("Annotation: TaintPropagation arg is not pointer");
697697
}
698698

699-
if (!isMocked) {
700-
buildCallKleeMakeMockAll(elem, mockName);
701-
isMocked = true;
702-
}
699+
// if (!isMocked) {
700+
// buildCallKleeMakeMockAll(elem, mockName);
701+
// isMocked = true;
702+
// }
703703
buildAnnotationTaintPropagation(elem, statement, func,
704704
"_arg_" + std::to_string(i) + "_");
705705
break;

runtime/Runtest/intrinsics.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void klee_make_mock(void *ret_array, size_t ret_nbytes, const char *fname) {
165165
}
166166

167167
// TODO: add for tests
168-
//void klee_make_mock_all(void *ret_array, const char *fname);
168+
//void klee_make_mock_all(void *ret_array, const char *fname) {}
169169
//void klee_add_taint(void *array, size_t taint_source) {}
170170
//void klee_clear_taint(void *array, size_t taint_source) {}
171171
//bool klee_check_taint_source(void *array, size_t taint_source) {}

0 commit comments

Comments
 (0)