summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-string-ext/mrblib
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2016-11-17 18:00:21 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2016-11-17 18:00:21 +0900
commit92be276d761ac7e2e7bd1ebe14625d9443b23eb3 (patch)
tree9454be9101170dce7c81750656e876683c9c14a3 /mrbgems/mruby-string-ext/mrblib
parent2e8ed9514feb74f4137e5835e74f256d52d6f191 (diff)
downloadmruby-92be276d761ac7e2e7bd1ebe14625d9443b23eb3.tar.gz
mruby-92be276d761ac7e2e7bd1ebe14625d9443b23eb3.zip
String#{strip,lstrip,rstrip} may cause OOB access
Diffstat (limited to 'mrbgems/mruby-string-ext/mrblib')
-rw-r--r--mrbgems/mruby-string-ext/mrblib/string.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/mrbgems/mruby-string-ext/mrblib/string.rb b/mrbgems/mruby-string-ext/mrblib/string.rb
index c3b765a5f..e6fbe7ddc 100644
--- a/mrbgems/mruby-string-ext/mrblib/string.rb
+++ b/mrbgems/mruby-string-ext/mrblib/string.rb
@@ -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