diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-04-11 10:02:37 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-04-11 10:02:37 +0000 |
| commit | 848201f7200427b09434bd795040d33e6bae5d17 (patch) | |
| tree | 95795093fb85be99d56bcbc1af7918bcf4103b62 /win32 | |
| parent | 6a8b8c0cab232a9a6cc79c34bfe64bd5b0031f46 (diff) | |
| download | ruby-848201f7200427b09434bd795040d33e6bae5d17.tar.gz ruby-848201f7200427b09434bd795040d33e6bae5d17.tar.xz ruby-848201f7200427b09434bd795040d33e6bae5d17.zip | |
* win32/win32.c (rb_w32_stat): check arguments. [ruby-dev:20007]
[ruby-win32:535]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
| -rw-r--r-- | win32/win32.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/win32/win32.c b/win32/win32.c index 004c8326d..ab9a438ca 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -2724,12 +2724,15 @@ int rb_w32_stat(const char *path, struct stat *st) { const char *p; - char *buf1 = ALLOCA_N(char, strlen(path) + 2); - char *buf2 = ALLOCA_N(char, MAXPATHLEN); - char *s; + char *buf1, *buf2, *s; int len; int ret; + if (!path || !st) { + errno = EFAULT; + return -1; + } + buf1 = ALLOCA_N(char, strlen(path) + 2); for (p = path, s = buf1; *p; p++, s++) { if (*p == '/') *s = '\\'; @@ -2749,6 +2752,7 @@ rb_w32_stat(const char *path, struct stat *st) strcat(buf1, "\\"); } else if (*p == '\\' || *p == ':') strcat(buf1, "."); + buf2 = ALLOCA_N(char, MAXPATHLEN); if (_fullpath(buf2, buf1, MAXPATHLEN)) { ret = stat(buf2, st); if (ret == 0) { |
