void ChrootChecker::Chdir(CheckerContext &C, const CallExpr *CE) const { ProgramStateRef state = C.getState(); ProgramStateManager &Mgr = state->getStateManager(); // If there are no jail state in the GDM, just return. const void *k = state->FindGDM(ChrootChecker::getTag()); if (!k) return; // After chdir("/"), enter the jail, set the enum value JAIL_ENTERED. const Expr *ArgExpr = CE->getArg(0); SVal ArgVal = state->getSVal(ArgExpr, C.getLocationContext()); if (const MemRegion *R = ArgVal.getAsRegion()) { R = R->StripCasts(); if (const StringRegion* StrRegion= dyn_cast<StringRegion>(R)) { const StringLiteral* Str = StrRegion->getStringLiteral(); if (Str->getString() == "/") state = Mgr.addGDM(state, ChrootChecker::getTag(), (void*) JAIL_ENTERED); } } C.addTransition(state); }