Bug 538234

Summary: _mysql_ConnectionObject_kill assumes that sizeof(long) == sizeof(int)
Product: [Fedora] Fedora Reporter: Dave Malcolm <dmalcolm>
Component: MySQL-pythonAssignee: Tom Lane <tgl>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: rawhideCC: hhorak, kylev, tgl
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 1.2.3-0.4.c1.fc12 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-12-11 18:28:55 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Dave Malcolm 2009-11-18 00:13:22 UTC
_mysql.c:_mysql_ConnectionObject_kill has this code:
  unsigned long pid;
  int r;
[snip]
  if (!PyArg_ParseTuple(args, "i:kill", &pid)) return NULL;

The 'i' format specifier implies an "int*", not an "unsigned long*".

Are these types guaranteed to be equally sized on every architecture?  (e.g. on a 64-bit big-endian CPU where sizeof(long) == 8 such as s390x, does it leave the 4 most significant bytes of "pid" uninitialized, thus killing random processes?)

Found using an experimental static analysis tool:
http://dmalcolm.livejournal.com/3689.html

Comment 1 Dave Malcolm 2009-11-18 00:14:15 UTC
(see http://docs.python.org/c-api/arg.html )

Comment 2 Tom Lane 2009-11-23 17:55:58 UTC
I agree, this is bogus.  Reported upstream at
https://sourceforge.net/tracker/?func=detail&aid=2902635&group_id=22307&atid=374932

Comment 3 Fedora Update System 2009-11-23 18:46:58 UTC
MySQL-python-1.2.3-0.4.c1.fc12 has been submitted as an update for Fedora 12.
http://admin.fedoraproject.org/updates/MySQL-python-1.2.3-0.4.c1.fc12

Comment 4 Fedora Update System 2009-11-23 18:47:03 UTC
MySQL-python-1.2.3-0.4.c1.fc11 has been submitted as an update for Fedora 11.
http://admin.fedoraproject.org/updates/MySQL-python-1.2.3-0.4.c1.fc11

Comment 5 Fedora Update System 2009-11-25 15:09:16 UTC
MySQL-python-1.2.3-0.4.c1.fc11 has been pushed to the Fedora 11 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update MySQL-python'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F11/FEDORA-2009-12089

Comment 6 Fedora Update System 2009-11-25 15:11:33 UTC
MySQL-python-1.2.3-0.4.c1.fc12 has been pushed to the Fedora 12 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update MySQL-python'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F12/FEDORA-2009-12101

Comment 7 Kyle VanderBeek 2009-12-08 00:19:04 UTC
I fixed this upstream by using the "k" to correctly unpack into an unsigned long:

http://mysql-python.svn.sourceforge.net/viewvc/mysql-python/branches/MySQLdb-1.2/MySQLdb/_mysql.c?r1=630&r2=634

Comment 8 Fedora Update System 2009-12-11 18:28:50 UTC
MySQL-python-1.2.3-0.4.c1.fc11 has been pushed to the Fedora 11 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 9 Fedora Update System 2009-12-11 18:29:53 UTC
MySQL-python-1.2.3-0.4.c1.fc12 has been pushed to the Fedora 12 stable repository.  If problems still persist, please make note of it in this bug report.