﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
1260	Buffer overflow in _WinAPI_GetLastErrorMessage()	danielkza	Valik	"{{{
Func _WinAPI_GetLastErrorMessage()
  Local $tText

  $tText = DllStructCreate(""char Text[4096]"")

 _WinAPI_FormatMessage($__WINAPCONSTANT_FORMAT_MESSAGE_FROM_SYSTEM, 0, _WinAPI_GetLastError(), 0, DllStructGetPtr($tText), 4096, 0)
  Return DllStructGetData($tText, ""Text"")
EndFunc   ;==>_WinAPI_GetLastErrorMessage
}}}

The 'nSize' parameter passed is not accounting for the terminating null character: it should be 4095, or the array size should be changed to 4097, according to [http://msdn.microsoft.com/en-us/library/ms679351(VS.85).aspx ""MSDN's example code""].

Another solution (a more elegant one, in my view) is letting FormatMessage allocate the buffer. The attached file contains a implementation of this method.


Thank you,
Daniel"	Bug	closed	3.3.1.5	Standard UDFs	3.3.1.3	Blocking	Fixed		
