Exemplo n.º 1
0
void
TaintedFlowAnalysisTransfer::visit(SgMinusOp *sgn)
   {
     TaintedFlowLattice* resLat = getLattice(sgn);

  // This sets the level
     resLat->copy(getLattice(sgn->get_operand()));
   }
Exemplo n.º 2
0
void
ConstantPropagationAnalysisTransfer::visit(SgMinusOp *sgn)
   {
     ConstantPropagationLattice* resLat = getLattice(sgn);

  // This sets the level
     resLat->copy(getLattice(sgn->get_operand()));

  // This fixes up the value if it is relevant (where level is neither top not bottom).
     resLat->setValue(-resLat->getValue());
   }
Exemplo n.º 3
0
bool 
TaintedFlowAnalysisTransfer::getLattices(const SgUnaryOp *sgn,  TaintedFlowLattice* &arg1Lat, TaintedFlowLattice* &arg2Lat, TaintedFlowLattice* &resLat)
  {
    arg1Lat = getLattice(sgn->get_operand());
    resLat  = getLattice(sgn);

    // Unary Update
    if(isSgMinusMinusOp(sgn) || isSgPlusPlusOp(sgn)) {
      arg2Lat = new TaintedFlowLattice(TaintedFlowLattice::untaintedValue);
    }
    //Dbg::dbg << "res="<<res.str()<<" arg1="<<arg1.str()<<" arg1Lat="<<arg1Lat<<", arg2Lat="<<arg2Lat<<"\n";
    //Dbg::dbg << "transfer B, resLat="<<resLat<<"\n";

    return (arg1Lat && arg2Lat && resLat);
  }
Exemplo n.º 4
0
void SandPile::caluclateDissipationdata(int point,std::vector<int> &dissipationRate) {
//int point,std::vector<int> &lat,std::vector<int> &critical, int timesteps, int &timestepsMax, int &size, std::vector<int> dissipationRate
	std::vector<int> critical(nrOfElements);
	std::vector<int> lat(getLattice());
	lat[point] += 1;
	int size = 0;
	int timeMax = 0;
	testDissipation(point,lat,critical,0,timeMax, size,dissipationRate);

//	coutLattice2d(critical);

//	int koord1[dimension];
//	int koord2[dimension];
//	coord(dimension,sidelength,point,koord1);
//	for(int i=0;i<nrOfElements;i++){
//		if(critical[i]==1){
//			coord(dimension,sidelength,i,koord2);
//			curDistance = radius(dimension,koord1,koord2);
//			if(curDistance >distance) distance = curDistance;
//		}
//	}

//	std::cout   << "\t" << "SandPile:: calculate Clusterdata" << "\t"
//				<< time << "\t"
//				<< size << "\t"
//				<< distance << "\t"
//				<< "\n";

}
Exemplo n.º 5
0
void SandPile::caluclateClusterdata(int point,int &time, int &size, int &distance) {
	std::vector<int> critical(nrOfElements);
	std::vector<int> lat(getLattice());
	lat[point] ++;
	testCritical(point,lat,critical,0,time, size);
	distance = 0;
	double curDistance = 0;

	int koord1[dimension];
	int koord2[dimension];
	coord(dimension,sidelength,point,koord1);
	for(int i=0;i<nrOfElements;i++){
		if(critical[i]==1){
			coord(dimension,sidelength,i,koord2);
			curDistance = radius(dimension,koord1,koord2);
			if(curDistance >distance) distance = curDistance;
		}
	}
//	std::cout   << "\t" << "SandPile:: calculate Clusterdata" << "\t"
//				<< time << "\t"
//				<< size << "\t"
//				<< distance << "\t"
//				<< "\n";

}
Exemplo n.º 6
0
void TaintAnalysisTransfer::visit(SgValueExp* sgn)
{
    ROSE_ASSERT(sgn != NULL);
    TaintLattice* res_lattice = getLattice(sgn);
    ROSE_ASSERT(res_lattice);
    modified = true;
    res_lattice->setUntainted();
}
Exemplo n.º 7
0
void
ConstantPropagationAnalysisTransfer::visit(SgIntVal *sgn)
   {
     ROSE_ASSERT(sgn != NULL);
     ConstantPropagationLattice* resLat = getLattice(sgn);
     ROSE_ASSERT(resLat != NULL);
     resLat->setValue(sgn->get_value());
     resLat->setLevel(ConstantPropagationLattice::constantValue);
   }
Exemplo n.º 8
0
bool TaintAnalysisTransfer::transferTaint(SgBinaryOp* sgn)
{
    bool modified = false;
    ROSE_ASSERT(sgn != NULL);
    TaintLattice* lhs_lat = getLattice(dynamic_cast<SgExpression*> (sgn->get_lhs_operand()));      // unsafe ??
    TaintLattice* rhs_lat = getLattice(dynamic_cast<SgExpression*> (sgn->get_rhs_operand()));
    TaintLattice* res_lattice = getLattice(dynamic_cast<SgExpression*> (sgn));
    // not a simple copy - do a meet to copy lattice information from right - left    
    if(lhs_lat) {
        modified = evaluateAndSetTaint(lhs_lat, rhs_lat);
        /*
        lhs_lat->copy(rhs_lat); modified |= true;
        */
    }
    if(res_lattice) {
        modified = evaluateAndSetTaint(res_lattice, rhs_lat);
        /*
        res_lattice->copy(rhs_lat); modified |= true;
        */
    }
    return modified;
}
Exemplo n.º 9
0
int main()
{ s32 v1[2], v2[2], r, p;

  printf("Enter r,p: ");
  scanf("%ld %ld", &r, &p);
  getLattice(v1, v2, r, p);
  printf("Spanning vectors of L_(r,p):\n");
  printf("v1 = (%ld, %ld)\n", v1[0], v1[1]);
  printf("v2 = (%ld, %ld)\n", v2[0], v2[1]);

  v1[0]=p; v1[1]=0;
  v2[0]=r; v2[1]=1;
  reduceBasis(v1,v2);
  printf("Doing reducedBasis() on (p,0) and (1,r) gives:\n");
  printf("v1 = (%ld, %ld)\n", v1[0], v1[1]);
  printf("v2 = (%ld, %ld)\n", v2[0], v2[1]);
 

} 
Exemplo n.º 10
0
void TaintAnalysisTransfer::visit(SgFunctionCallExp* sgn)
{
    ROSE_ASSERT(sgn != NULL);

    // NOTE: This is applicable only for statically resolvable functions
    SgFunctionDeclaration* fn_decl = sgn->getAssociatedFunctionDeclaration();
    TaintLattice* res_lattice = getLattice(sgn);
    ROSE_ASSERT(res_lattice != NULL);
    /*
    if(!this->functionsinfile->isFunctionInFile(fn_decl)) {
        modified = true;
        res_lattice->setTainted();
    }
    */
    SecureFunctionType* attr = dynamic_cast<SecureFunctionType*> (sgn->getAttribute("SECURE_TYPE") );
    if(! attr->isSecure() ) {
        res_lattice->setTainted();
    }
    else {
        res_lattice->setUntainted();
    }
    modified = true;
}
Exemplo n.º 11
0
void
TaintedFlowAnalysisTransfer::visit(SgUnaryAddOp *sgn)
   {
     TaintedFlowLattice* resLat = getLattice(sgn);
     resLat->copy(getLattice(sgn->get_operand()));
   }
Exemplo n.º 12
0
void
TaintedFlowAnalysisTransfer::visit(SgFunctionCallExp *sgn)
   {
     TaintedFlowLattice* resLat = getLattice(sgn);
     resLat->setLevel(TaintedFlowLattice::taintedValue);
   }
Exemplo n.º 13
0
void
TaintedFlowAnalysisTransfer::visit(SgIntVal *sgn)
   {
     TaintedFlowLattice* resLat = getLattice(sgn);
     resLat->setLevel(TaintedFlowLattice::untaintedValue);
   }
Exemplo n.º 14
0
void
ConstantPropagationAnalysisTransfer::visit(SgUnaryAddOp *sgn)
   {
     ConstantPropagationLattice* resLat = getLattice(sgn);
     resLat->copy(getLattice(sgn->get_operand()));
   }
Exemplo n.º 15
0
std::vector<int> SandPile::SideZeros() {
	return SideZeros(getLattice());
}
Exemplo n.º 16
0
 PointsToAnalysisTransfer::AbstractObjectSetPtr 
 PointsToAnalysisTransfer::getLatticeCommon(MemLocObjectPtr p)
 {
   return getLattice(AbstractObjectPtr(p));
 }