From 731921916b73b8f5c9c637fce44dad68dbc22c27 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Tue, 16 Apr 2019 16:05:13 +0200 Subject: [PATCH] limit destination tag --- src/actions/ripple/SendFormValidationActions.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/actions/ripple/SendFormValidationActions.js b/src/actions/ripple/SendFormValidationActions.js index b8a8911a..3155d994 100644 --- a/src/actions/ripple/SendFormValidationActions.js +++ b/src/actions/ripple/SendFormValidationActions.js @@ -20,6 +20,7 @@ import AddressValidator from 'wallet-address-validator'; const ABS_RE = new RegExp('^[0-9]+$'); const NUMBER_RE: RegExp = new RegExp('^(0|0\\.([0-9]+)?|[1-9][0-9]*\\.?([0-9]+)?|\\.[0-9]+)$'); const XRP_6_RE = new RegExp('^(0|0\\.([0-9]{0,6})?|[1-9][0-9]*\\.?([0-9]{0,6})?|\\.[0-9]{0,6})$'); +const U_INT_32 = 0xffffffff; /* * Called from SendFormActions.observe @@ -338,9 +339,15 @@ export const destinationTagValidation = ($state: State): PayloadAction => if (!state.touched.destinationTag) return state; const { destinationTag } = state; + if (destinationTag.length > 0 && !destinationTag.match(ABS_RE)) { state.errors.destinationTag = 'Destination tag must be an absolute number'; } + + if (parseInt(destinationTag, 10) > U_INT_32) { + state.errors.destinationTag = 'Number is too big'; + } + return state; };