Permalink
Browse files

String#{strip,lstrip,rstrip} may cause OOB access

  • Loading branch information...
matz committed Nov 17, 2016
1 parent 2e8ed95 commit 92be276d761ac7e2e7bd1ebe14625d9443b23eb3
Showing with 4 additions and 4 deletions.
  1. +4 −4 mrbgems/mruby-string-ext/mrblib/string.rb
@@ -45,7 +45,7 @@ def clear
def lstrip
a = 0
z = self.size - 1
a += 1 while " \f\n\r\t\v".include?(self[a]) and a <= z
a += 1 while a <= z and " \f\n\r\t\v".include?(self[a])
(z >= 0) ? self[a..z] : ""
end
@@ -62,7 +62,7 @@ def lstrip
def rstrip
a = 0
z = self.size - 1
z -= 1 while " \f\n\r\t\v\0".include?(self[z]) and a <= z
z -= 1 while a <= z and " \f\n\r\t\v\0".include?(self[z])
(z >= 0) ? self[a..z] : ""
end
@@ -78,8 +78,8 @@ def rstrip
def strip
a = 0
z = self.size - 1
a += 1 while " \f\n\r\t\v".include?(self[a]) and a <= z
z -= 1 while " \f\n\r\t\v\0".include?(self[z]) and a <= z
a += 1 while a <= z and " \f\n\r\t\v".include?(self[a])
z -= 1 while a <= z and " \f\n\r\t\v\0".include?(self[z])
(z >= 0) ? self[a..z] : ""
end

0 comments on commit 92be276

Please sign in to comment.