Bug #33547 stack corruption after call to mysql_init()
Submitted: 28 Dec 2007 3:50 Modified: 8 Mar 2008 13:09
Reporter: sumant naikkhanvte Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: C API (client library) Severity:S2 (Serious)
Version:5.1 OS:Linux (RHEL)
Assigned to: CPU Architecture:Any

[28 Dec 2007 3:50] sumant naikkhanvte
Description:
I was allocating the MYSQL object on stack (as a local variable) and was seeing stack corruption after mysql_init() call. When I did a memset(&obj, 0, sizeof(MYSQL)) on the object before the mysql_init() call, the stack corruption was gone. I suspect that there are some unwarranted assumptions about the object being passed to mysql_init().

How to repeat:
Have the object take random non-zero values and try passing it to mysql_init(). Perhaps there are some pointers within the object (I haven't checked) and mysql_init() has checks to the tune of:
if (obj->ptr != NULL) {
...
}

Suggested fix:
The MYSQL object should be zeroed out internally before using using it further in mysql_init()
[28 Dec 2007 5:37] Valeriy Kravchuk
Thank you for a problem report. Please, send the exact code you use.
[28 Dec 2007 5:47] sumant naikkhanvte
It would not be possible for me to provide either the code or snippets thereof. Please excuse me for this.
[4 Jan 2008 11:08] Susanne Ebrecht
Sorry, but we are not able to verify this, without a short test case from you, in which the issue occurs.
[5 Feb 2008 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[8 Feb 2008 13:09] Susanne Ebrecht
We still can't analyze this, without a short test case or a description, how we can repeat your issue.
[9 Mar 2008 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".