diff options
| author | ocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-03-17 05:47:18 +0000 |
|---|---|---|
| committer | ocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-03-17 05:47:18 +0000 |
| commit | d5ef71e5f71b712e63d342d225706e1596eda1a4 (patch) | |
| tree | 7f6ed5f2927656de7d944f40fb6bddc973d02263 /dir.c | |
| parent | d2a4a520c702845228c757577346baf7273e45f3 (diff) | |
| download | ruby-d5ef71e5f71b712e63d342d225706e1596eda1a4.tar.gz ruby-d5ef71e5f71b712e63d342d225706e1596eda1a4.tar.xz ruby-d5ef71e5f71b712e63d342d225706e1596eda1a4.zip | |
* dir.c (range): fix possible "\0" overrun. (in case of "\0-")
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@5966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
| -rw-r--r-- | dir.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -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)) |
