Skip to content

Commit 900ae45

Browse files
authored
summary function for Swift's String.append method (#603)
1 parent 06fd409 commit 900ae45

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/PhasarLLVM/DataFlow/IfdsIde/Problems/IFDSTaintAnalysis.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,17 @@ IFDSTaintAnalysis::FlowFunctionPtrType
281281
IFDSTaintAnalysis::getSummaryFlowFunction(
282282
[[maybe_unused]] IFDSTaintAnalysis::n_t CallSite,
283283
[[maybe_unused]] IFDSTaintAnalysis::f_t DestFun) {
284-
// Don't use a special summary
284+
// $sSS1poiyS2S_SStFZ is Swift's String append method
285+
// if concat a tainted string with something else the
286+
// result should be tainted
287+
if (DestFun->getName().equals("$sSS1poiyS2S_SStFZ")) {
288+
const auto *CS = llvm::cast<llvm::CallBase>(CallSite);
289+
290+
return generateFlowIf<d_t>(CallSite, [CS](d_t Source) {
291+
return ((Source == CS->getArgOperand(1)) ||
292+
(Source == CS->getArgOperand(3)));
293+
});
294+
}
285295
return nullptr;
286296
}
287297

0 commit comments

Comments
 (0)