Language: Go
Label: safe
CWE: CWE-20 \u2014 Improper Input Validation
The product receives input or data, but it does
        not validate or incorrectly validates that the input has the
        properties that are required to process the data safely and
        correctly.

Code:
func (e *ERC20LogicView) FindAssetLimitsUpdated(
	update *types.ERC20AssetLimitsUpdated,
	blockNumber uint64, logIndex uint64,
	ethAssetAddress string,
	txHash string,
) error {
	bf, err := bridgecontract.NewErc20BridgeLogicRestrictedFilterer(
		e.clt.CollateralBridgeAddress(), e.clt)
	if err != nil {
		return err
	}

	resp := "ok"
	defer func() {
		metrics.EthCallInc("find_asset_limits_updated", update.VegaAssetID, resp)
	}()

	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
	defer cancel()
	iter, err := bf.FilterAssetLimitsUpdated(
		&bind.FilterOpts{
			Start:   blockNumber - 1,
			Context: ctx,
		},
		[]ethcommon.Address{ethcommon.HexToAddress(ethAssetAddress)},
	)
	if err != nil {
		resp = getMaybeHTTPStatus(err)
		return err
	}
	defer iter.Close()

	var event *bridgecontract.Erc20BridgeLogicRestrictedAssetLimitsUpdated

	for iter.Next() {
		eventLifetimeLimit, _ := num.UintFromBig(iter.Event.LifetimeLimit)
		eventWithdrawThreshold, _ := num.UintFromBig(iter.Event.WithdrawThreshold)
		if update.LifetimeLimits.EQ(eventLifetimeLimit) &&
			update.WithdrawThreshold.EQ(eventWithdrawThreshold) &&
			iter.Event.Raw.BlockNumber == blockNumber &&
			uint64(iter.Event.Raw.Index) == logIndex &&
			iter.Event.Raw.TxHash.Hex() == txHash {
			event = iter.Event
			break
		}
	}

	if event == nil {
		return ErrUnableToFindERC20AssetLimitsUpdated
	}

	// now ensure we have enough confirmations
	if err := e.ethConfs.Check(event.Raw.BlockNumber); err != nil {
		return err
	}

	return nil
}