Пример #1
0
Bool UnsafePartialValidateInst(const NCDecoderInst *dinst) {
  NCValidatorState *vstate = NCVALIDATOR_STATE_DOWNCAST(dinst->dstate);
  Bool result = FALSE;

  NACL_FLAG_unsafe_single_inst32_mode = TRUE;
  NCStatsInit(vstate);
  if (ValidateInst(dinst)) {
    result = vstate->stats.sawfailure == 0;
  };
  NACL_FLAG_unsafe_single_inst32_mode = FALSE;
  return result;
}
Пример #2
0
/*
 * Check that mstate_new is a valid replacement instruction for mstate_old.
 * Note that mstate_old was validated when it was inserted originally.
 */
static Bool ValidateInstReplacement(NCDecoderStatePair* tthis,
                                    NCDecoderInst *dinst_old,
                                    NCDecoderInst *dinst_new) {
  dinst_new->unchanged = memcmp(dinst_old->inst.bytes.byte,
                                dinst_new->inst.bytes.byte,
                                dinst_new->inst.bytes.length) == 0;
  ValidateInst(dinst_new);

  if (dinst_old->opinfo->insttype == NACLi_INDIRECT
    || dinst_new->opinfo->insttype == NACLi_INDIRECT) {
    /* Verify that nacljmps never change */
    ValidateIndirect5Replacement(dinst_old, dinst_new);
  }
  return TRUE;
}
Пример #3
0
/*
 * Check that mstate_new is a valid replacement instruction for mstate_old.
 * Note that mstate_old was validated when it was inserted originally.
 */
void ValidateInstReplacement(const struct NCDecoderState *mstate_old,
                             const struct NCDecoderState *mstate_new) {
  /* Call single instruction validator first, will call ValidateIndirect5() */
  ValidateInst(mstate_new);

  /* Location/length must match */
  if (mstate_old->inst.length != mstate_new->inst.length
    || mstate_old->vpc != mstate_new->vpc) {
    BadInstructionError(mstate_new,
                        "New instruction does not match old instruction size");
    Stats_BadInstLength(mstate_new->vstate);
  }

  if (mstate_old->opinfo->insttype == NACLi_INDIRECT
    || mstate_new->opinfo->insttype == NACLi_INDIRECT) {
    /* Verify that nacljmps never change */
    ValidateIndirect5Replacement(mstate_old, mstate_new);
  }
}