mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Thu, 29 Jul 2010 23:33:21 +0000 nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
merge revision(s) 28794:28796: * file.c (file_expand_path): should check if could find user. [ruby-core:31538] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@28795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e Signed-off-by: URABE, Shyouhei <shyouhei@ruby-lang.org> * file.c (file_expand_path): home directory must be absolute. [ruby-core:31537] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@28796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e Signed-off-by: URABE, Shyouhei <shyouhei@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@29859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
85697688b4
commit
fb5c60ddbe
4 changed files with 41 additions and 4 deletions
10
ChangeLog
10
ChangeLog
|
|
@ -1,3 +1,13 @@
|
||||||
|
Fri Jul 30 08:51:51 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* file.c (file_expand_path): home directory must be absolute.
|
||||||
|
[ruby-core:31537]
|
||||||
|
|
||||||
|
Fri Jul 30 08:33:20 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* file.c (file_expand_path): should check if could find user.
|
||||||
|
[ruby-core:31538]
|
||||||
|
|
||||||
Thu Jul 29 22:43:57 2010 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
|
Thu Jul 29 22:43:57 2010 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
|
||||||
|
|
||||||
* lib/webrick/ssl.rb (WEBrick::Utils.create_self_signed_cert): wrongly
|
* lib/webrick/ssl.rb (WEBrick::Utils.create_self_signed_cert): wrongly
|
||||||
|
|
|
||||||
18
file.c
18
file.c
|
|
@ -2530,6 +2530,7 @@ file_expand_path(fname, dname, result)
|
||||||
tainted = OBJ_TAINTED(fname);
|
tainted = OBJ_TAINTED(fname);
|
||||||
|
|
||||||
if (s[0] == '~') {
|
if (s[0] == '~') {
|
||||||
|
long userlen = 0;
|
||||||
if (isdirsep(s[1]) || s[1] == '\0') {
|
if (isdirsep(s[1]) || s[1] == '\0') {
|
||||||
const char *dir = getenv("HOME");
|
const char *dir = getenv("HOME");
|
||||||
|
|
||||||
|
|
@ -2557,9 +2558,10 @@ file_expand_path(fname, dname, result)
|
||||||
s++;
|
s++;
|
||||||
#endif
|
#endif
|
||||||
s = nextdirsep(b = s);
|
s = nextdirsep(b = s);
|
||||||
BUFCHECK(bdiff + (s-b) >= buflen);
|
userlen = s - b;
|
||||||
memcpy(p, b, s-b);
|
BUFCHECK(bdiff + userlen >= buflen);
|
||||||
p += s-b;
|
memcpy(p, b, userlen);
|
||||||
|
p += userlen;
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
#ifdef HAVE_PWD_H
|
#ifdef HAVE_PWD_H
|
||||||
pwPtr = getpwnam(buf);
|
pwPtr = getpwnam(buf);
|
||||||
|
|
@ -2572,8 +2574,18 @@ file_expand_path(fname, dname, result)
|
||||||
strcpy(buf, pwPtr->pw_dir);
|
strcpy(buf, pwPtr->pw_dir);
|
||||||
p = buf + strlen(pwPtr->pw_dir);
|
p = buf + strlen(pwPtr->pw_dir);
|
||||||
endpwent();
|
endpwent();
|
||||||
|
#else
|
||||||
|
rb_raise(rb_eArgError, "can't find user %s", buf);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
if (!is_absolute_path(RSTRING_PTR(result))) {
|
||||||
|
if (userlen) {
|
||||||
|
rb_raise(rb_eArgError, "non-absolute home of %.*s", userlen, s);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rb_raise(rb_eArgError, "non-absolute home");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#ifdef DOSISH_DRIVE_LETTER
|
#ifdef DOSISH_DRIVE_LETTER
|
||||||
/* skip drive letter */
|
/* skip drive letter */
|
||||||
|
|
|
||||||
|
|
@ -353,6 +353,21 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
assert_equal(@file, File.expand_path(@file + "."))
|
assert_equal(@file, File.expand_path(@file + "."))
|
||||||
assert_equal(@file, File.expand_path(@file + "::$DATA"))
|
assert_equal(@file, File.expand_path(@file + "::$DATA"))
|
||||||
end
|
end
|
||||||
|
assert_kind_of(String, File.expand_path("~"))
|
||||||
|
assert_raise(ArgumentError) { File.expand_path("~foo_bar_baz_unknown_user_wahaha") }
|
||||||
|
assert_raise(ArgumentError) { File.expand_path("~foo_bar_baz_unknown_user_wahaha", "/") }
|
||||||
|
begin
|
||||||
|
bug3630 = '[ruby-core:31537]'
|
||||||
|
home = ENV["HOME"]
|
||||||
|
ENV["HOME"] = nil
|
||||||
|
assert_raise(ArgumentError) { File.expand_path("~") }
|
||||||
|
ENV["HOME"] = "~"
|
||||||
|
assert_raise(ArgumentError, bug3630) { File.expand_path("~") }
|
||||||
|
ENV["HOME"] = "."
|
||||||
|
assert_raise(ArgumentError, bug3630) { File.expand_path("~") }
|
||||||
|
ensure
|
||||||
|
ENV["HOME"] = home
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_basename
|
def test_basename
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define RUBY_RELEASE_DATE "2010-11-22"
|
#define RUBY_RELEASE_DATE "2010-11-22"
|
||||||
#define RUBY_VERSION_CODE 187
|
#define RUBY_VERSION_CODE 187
|
||||||
#define RUBY_RELEASE_CODE 20101122
|
#define RUBY_RELEASE_CODE 20101122
|
||||||
#define RUBY_PATCHLEVEL 308
|
#define RUBY_PATCHLEVEL 309
|
||||||
|
|
||||||
#define RUBY_VERSION_MAJOR 1
|
#define RUBY_VERSION_MAJOR 1
|
||||||
#define RUBY_VERSION_MINOR 8
|
#define RUBY_VERSION_MINOR 8
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue