示例#1
0
void TaintWarning::WarnIfTainted(CStrRef s, const taint_t bit) {
  const TaintData& td = s.get()->getTaintDataRefConst();
  if (!(td.getTaint() & bit)) { return; }

  bool force_warning = false;
  std::string buf, aux;

  buf = "Using a ";
  switch (bit) {
    case TAINT_BIT_HTML:
      buf += "HTML-unsafe (tainted)";
      if (TaintTracer::IsTraceEnabled(TAINT_BIT_TRACE_HTML)) {
        force_warning = true;
        aux = TaintTracer::ExtractTrace(td.getTaintTrace());
      }
      break;

    case TAINT_BIT_MUTATED:
      buf += "non-static (tainted)";
      break;

    case TAINT_BIT_SQL:
      buf += "SQL-unsafe (tainted)";
      break;

    case TAINT_BIT_SHELL:
      buf += "shell-unsafe (tainted)";
      break;

    case TAINT_BIT_ALL:
      buf += "tainted";
      break;

    default:
      return;
  }
  buf += " string!\n";

  if (RuntimeOption::EnableTaintWarnings || force_warning) {
    buf += aux;
    buf += "\n";

    buf += "---begin output---\n";
    buf += s.c_str();
    buf += "\n";
    buf += "----end output----\n";

    ZeroCount(bit);
    raise_warning(buf);
  } else {
    IncCount(bit);
  }
}
示例#2
0
bool ParticleChannelMap::SetCount(int n)
{
	if (n < 0)	return false;
	if (n == 0)	{
		ZeroCount();
		return true;
	}

	if (chanUVVert() == NULL)
		_chanUVVert() = new ParticleChannelTabUVVert();
	DbgAssert(chanUVVert());
	if (chanUVVert() == NULL) return false;

	if (chanTVFace() == NULL)
		_chanTVFace() = new ParticleChannelTabTVFace();
	DbgAssert(chanTVFace());
	if (chanTVFace() == NULL) return false;
	
	bool res1 = _chanUVVert()->SetCount(n);
	bool res2 = _chanTVFace()->SetCount(n);
	return (res1 && res2);
}