mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
String#{strip,lstrip,rstrip} may cause OOB access
This commit is contained in:
@@ -45,7 +45,7 @@ class String
|
||||
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 @@ class String
|
||||
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 @@ class String
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user