summaryrefslogtreecommitdiffstats
path: root/dir.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-17 04:05:18 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-17 04:05:18 +0000
commita110b4c7ed2779e413b6d4d19c714b9f6b24a960 (patch)
tree9e2ab81ebca1f2e67f340aa0d11fa27f885a56cf /dir.c
parent18c8279795ef0e1fb27fc3c484d3f3260c18b2a9 (diff)
downloadruby-a110b4c7ed2779e413b6d4d19c714b9f6b24a960.tar.gz
ruby-a110b4c7ed2779e413b6d4d19c714b9f6b24a960.tar.xz
ruby-a110b4c7ed2779e413b6d4d19c714b9f6b24a960.zip
* dir.c (rb_push_glob): fix overrun. [ruby-dev:24886]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@7296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/dir.c b/dir.c
index 970d13edc..5e8b89c7f 100644
--- a/dir.c
+++ b/dir.c
@@ -1500,9 +1500,14 @@ rb_push_glob(str, flags) /* '\0' is delimiter */
while (offset < RSTRING(str)->len) {
int status = push_glob(ary, str, offset, flags);
+ char *p, *pend;
if (status) rb_jump_tag(status);
- offset += strlen(RSTRING(str)->ptr+offset) + 1;
- while (!RSTRING(str)->ptr[offset]) offset++;
+ p = RSTRING(str)->ptr + offset;
+ p += strlen(p) + 1;
+ pend = RSTRING(str)->ptr + RSTRING(str)->len;
+ while (p < pend && !*p)
+ p++;
+ offset = p - RSTRING(str)->ptr;
}
if (rb_block_given_p()) {