ruby-changes:65055
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Wed, 27 Jan 2021 09:30:33 +0900 (JST)
Subject: [ruby-changes:65055] a2c069fca9 (master): win32/file.c:rb_file_expand_path_internal: delete OBJ_TAINT
https://git.ruby-lang.org/ruby.git/commit/?id=a2c069fca9 From a2c069fca9ea80edef8f6441aeaecdfe4d1645a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Wed, 20 Jan 2021 11:59:05 +0900 Subject: win32/file.c:rb_file_expand_path_internal: delete OBJ_TAINT Makes no sense any longer. --- win32/file.c | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/win32/file.c b/win32/file.c index 5c34bd4..d92cec6 100644 --- a/win32/file.c +++ b/win32/file.c @@ -37,8 +37,6 @@ IS_ABSOLUTE_PATH_P(const WCHAR *path, size_t len) https://github.com/ruby/ruby/blob/trunk/win32/file.c#L37 #define INVALID_CODE_PAGE 51932 #define PATH_BUFFER_SIZE MAX_PATH * 2 -#define insecure_obj_p(obj, level) ((level) > 0 && OBJ_TAINTED(obj)) - /* defined in win32/win32.c */ #define system_code_page rb_w32_filecp #define mbstr_to_wstr rb_w32_mbstr_to_wstr @@ -288,10 +286,6 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na https://github.com/ruby/ruby/blob/trunk/win32/file.c#L286 wchar_t path_drive = L'\0', dir_drive = L'\0'; int ignore_dir = 0; rb_encoding *path_encoding; - int tainted = 0; - - /* tainted if path is tainted */ - tainted = OBJ_TAINTED(path); /* get path encoding */ if (NIL_P(dir)) { @@ -328,9 +322,6 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na https://github.com/ruby/ruby/blob/trunk/win32/file.c#L322 /* expand '~' only if NOT rb_file_absolute_path() where `abs_mode` is 1 */ if (abs_mode == 0 && wpath_len > 0 && wpath_pos[0] == L'~' && (wpath_len == 1 || IS_DIR_SEPARATOR_P(wpath_pos[1]))) { - /* tainted if expanding '~' */ - tainted = 1; - whome = rb_w32_home_dir(); if (whome == NULL) { free(wpath); @@ -409,9 +400,6 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na https://github.com/ruby/ruby/blob/trunk/win32/file.c#L400 if (abs_mode == 0 && wdir_len > 0 && wdir_pos[0] == L'~' && (wdir_len == 1 || IS_DIR_SEPARATOR_P(wdir_pos[1]))) { - /* tainted if expanding '~' */ - tainted = 1; - whome = rb_w32_home_dir(); if (whome == NULL) { free(wpath); @@ -516,10 +504,6 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na https://github.com/ruby/ruby/blob/trunk/win32/file.c#L504 } if (wdir_len) { - /* tainted if dir is used and dir is tainted */ - if (!tainted && OBJ_TAINTED(dir)) - tainted = 1; - wcsncpy(buffer_pos, wdir_pos, wdir_len); buffer_pos += wdir_len; } @@ -545,10 +529,6 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na https://github.com/ruby/ruby/blob/trunk/win32/file.c#L529 /* Ensure buffer is NULL terminated */ buffer_pos[0] = L'\0'; - /* tainted if path is relative */ - if (!tainted && !IS_ABSOLUTE_PATH_P(buffer, buffer_len)) - tainted = 1; - /* FIXME: Make this more robust */ /* Determine require buffer size */ size = GetFullPathNameW(buffer, PATH_BUFFER_SIZE, wfullpath_buffer, NULL); @@ -591,10 +571,6 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na https://github.com/ruby/ruby/blob/trunk/win32/file.c#L571 rb_str_set_len(result, 0); result = append_wstr(result, wfullpath, size, path_cp, path_encoding); - /* makes the result object tainted if expanding tainted strings or returning modified path */ - if (tainted) - OBJ_TAINT(result); - /* TODO: better cleanup */ if (buffer) xfree(buffer); -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/