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:
parent
ba3da9af7d
commit
802d4f9fb2
1 changed files with 3 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue