summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-03-17 05:47:18 +0000
committerocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-03-17 05:47:18 +0000
commita42f910d199930f7e7a6a86f5b851ce1f098f4d7 (patch)
tree7f6ed5f2927656de7d944f40fb6bddc973d02263 /dir.c
parentbf5f1e771ad1c1295f6a82eb95a9b92320a9ae9a (diff)
* dir.c (range): fix possible "\0" overrun. (in case of "\0-")
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@5966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/dir.c b/dir.c
index b26eda4..efd8f45 100644
--- a/dir.c
+++ b/dir.c
@@ -107,25 +107,25 @@ range(pat, test, flags)
test = downcase(test);
- while (*pat) {
+ while (*pat != ']') {
int cstart, cend;
+ if (escape && *pat == '\\')
+ pat++;
cstart = cend = *pat++;
- if (cstart == ']')
- return ok == not ? 0 : pat;
- else if (escape && cstart == '\\')
- cstart = cend = *pat++;
+ if (!cstart)
+ return 0;
if (*pat == '-' && pat[1] != ']') {
- if (escape && pat[1] == '\\')
+ pat++;
+ if (escape && *pat == '\\')
pat++;
- cend = pat[1];
+ cend = *pat++;
if (!cend)
return 0;
- pat += 2;
}
if (downcase(cstart) <= test && test <= downcase(cend))
ok = 1;
}
- return 0;
+ return ok == not ? 0 : pat + 1;
}
#define ISDIRSEP(c) (pathname && isdirsep(c))