Bug #9323 memset called with wrong parameter order
Submitted: 21 Mar 2005 23:30 Modified: 25 Mar 2005 20:38
Reporter: [ name withheld ] Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.10a OS:Any (all)
Assigned to: Jim Winstead CPU Architecture:Any

[21 Mar 2005 23:30] [ name withheld ]
Description:
memset is called with the wrong parameter order in at least these four places:

mysql-4.1.10a/ndb/src/kernel/vm/VMSignal.cpp:  memset(&header, sizeof(header), 0);
mysql-4.1.10a/ndb/src/kernel/vm/VMSignal.cpp:  memset(theData, sizeof(theData), 0);
mysql-4.1.10a/bdb/btree/bt_open.c:		memset(buf, dbp->pgsize, 0);
mysql-4.1.10a/bdb/hash/hash_open.c:		memset(buf, dbp->pgsize, 0);

The writer's intent is evidently to zero out some memory, but instead the call is a no-op.  I have not done the analysis to see whether any visible fault results from any of these.

How to repeat:
grep for places where third arg to memset is constant zero.

Suggested fix:
memset(x, 0, sizeof(x))
[23 Mar 2005 0:00] 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/internals/23306
[25 Mar 2005 20:38] Jim Winstead
Pushed, will be included in 4.1.11 and 5.0.4.

Thanks for the report.