[前][次][番号順一覧][スレッド一覧]

ruby-changes:45278

From: nagachika <ko1@a...>
Date: Tue, 17 Jan 2017 04:52:01 +0900 (JST)
Subject: [ruby-changes:45278] nagachika:r57351 (ruby_2_3): merge revision(s) 57135, 57136: [Backport #13058]

nagachika	2017-01-17 04:51:56 +0900 (Tue, 17 Jan 2017)

  New Revision: 57351

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57351

  Log:
    merge revision(s) 57135,57136: [Backport #13058]
    
    Fixed potentially buffer overrun.
    
    * win32/win32.c (winnt_stat): the return value of `get_final_path` is the
      expected buffer length, not the actuall filled length.
    
    * win32/win32.c (winnt_stat): `finalname` may be accessed in the outer block of
      its definition via `path`.

  Modified directories:
    branches/ruby_2_3/
  Modified files:
    branches/ruby_2_3/version.h
    branches/ruby_2_3/win32/win32.c
Index: ruby_2_3/win32/win32.c
===================================================================
--- ruby_2_3/win32/win32.c	(revision 57350)
+++ ruby_2_3/win32/win32.c	(revision 57351)
@@ -5429,11 +5429,11 @@ static int https://github.com/ruby/ruby/blob/trunk/ruby_2_3/win32/win32.c#L5429
 winnt_stat(const WCHAR *path, struct stati64 *st)
 {
     HANDLE f;
+    WCHAR finalname[MAX_PATH];
 
     memset(st, 0, sizeof(*st));
     f = open_special(path, 0, 0);
     if (f != INVALID_HANDLE_VALUE) {
-	WCHAR finalname[MAX_PATH];
 	const DWORD attr = stati64_handle(f, st);
 	const DWORD len = get_final_path(f, finalname, numberof(finalname), 0);
 	CloseHandle(f);
@@ -5442,7 +5442,7 @@ winnt_stat(const WCHAR *path, struct sta https://github.com/ruby/ruby/blob/trunk/ruby_2_3/win32/win32.c#L5442
 	}
 	st->st_mode = fileattr_to_unixmode(attr, path);
 	if (len) {
-	    finalname[len] = L'\0';
+	    finalname[min(len, PATH_MAX-1)] = L'\0';
 	    path = finalname;
 	    if (wcsncmp(path, namespace_prefix, numberof(namespace_prefix)) == 0)
 		path += numberof(namespace_prefix);
Index: ruby_2_3/version.h
===================================================================
--- ruby_2_3/version.h	(revision 57350)
+++ ruby_2_3/version.h	(revision 57351)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1
 #define RUBY_VERSION "2.3.3"
 #define RUBY_RELEASE_DATE "2017-01-17"
-#define RUBY_PATCHLEVEL 235
+#define RUBY_PATCHLEVEL 236
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 1

Property changes on: ruby_2_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r57135


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]