Bug #27490 Function to log to NT event log could allocate memory
Submitted: 28 Mar 2007 7:44 Modified: 10 Apr 2007 18:09
Reporter: Magnus Blåudd Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Errors Severity:S2 (Serious)
Version:5.0.40 OS:Windows (Windows)
Assigned to: Magnus Blåudd CPU Architecture:Any

[28 Mar 2007 7:44] Magnus Blåudd
Description:
The function 'print_buffer_to_nt_event_log' might allocate memroy with "new" if the supplied buffer is considered too short to add terminating CR/LF's.

Since that function ispotentially used to log an "out of memory" error it's not advisable to use "new", better would be to just overwrite last chars in the buffer to avoid the "new" and lots of code.

How to repeat:
MCI

Suggested fix:
Remove the new and truncate the string to make room for the ending CR/LF's
[28 Mar 2007 8:12] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/23110

ChangeSet@1.2409, 2007-03-28 10:12:33+02:00, msvensson@pilot.blaudden +1 -0
  Bug#27490 Function to log to NT event log could allocate memory
  - Change 'print_buffer_to_nt_event_log' to overwrite the string
  if the buffer is not long enough to hold the ending CR/LF's
  - Make functions static
  - Remove the "hack" intended to force 'print_buffer_to_nt_event_log'
   never to use "new"
[6 Apr 2007 17:21] Bugs System
Pushed into 5.0.40
[6 Apr 2007 17:24] Bugs System
Pushed into 5.1.18-beta
[10 Apr 2007 18:00] Timothy Smith
For documentation: 

In out-of-memory conditions, the server might crash or otherwise not report an error to the Windows event log.
[10 Apr 2007 18:09] Paul DuBois
Noted in 5.0.40, 5.1.18 changelogs.