1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

registry.rb: fix buffer overflow

* ext/win32/lib/win32/registry.rb (Win32::Registry::Error#initialize):
  should not re-use sliced string as buffer, to get rid of buffer
  overflow.  [ruby-core:65295] [Bug #10300]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-12-23 08:58:53 +00:00
parent ba3da9af7d
commit 802d4f9fb2

View file

@ -174,11 +174,11 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
FormatMessageW = Kernel32.extern "int FormatMessageW(int, void *, int, int, void *, int, void *)", :stdcall
def initialize(code)
@code = code
msg = WCHAR_NUL * 1024
buff = WCHAR_NUL * 1024
lang = 0
begin
len = FormatMessageW.call(0x1200, 0, code, lang, msg, 1024, 0)
msg = msg.byteslice(0, len * WCHAR_SIZE)
len = FormatMessageW.call(0x1200, 0, code, lang, buff, 1024, 0)
msg = buff.byteslice(0, len * WCHAR_SIZE)
msg.delete!(WCHAR_CR)
msg.chomp!
msg.encode!(LOCALE)