Skip to content

Commit

Permalink
Fix check data length logic
Browse files Browse the repository at this point in the history
If human-readable part dose not found, Bech32#decode returns nil.
  • Loading branch information
azuchi committed May 11, 2017
1 parent 1274ee7 commit 590d898
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ref/ruby/bech32.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def decode(bech)
bech = bech.downcase
# check data length
pos = bech.rindex(SEPARATOR)
return nil if pos.nil? || pos + 7 > bech.length || bech.length > 90
return nil if pos.nil? || pos < 1 || pos + 7 > bech.length || bech.length > 90
# check valid charset
bech[pos+1..-1].each_char{|c|return nil unless CHARSET.include?(c)}
# split hrp and data
Expand Down

0 comments on commit 590d898

Please sign in to comment.