Bug 697470 - os.lstat() returns negative values for owner and/or group for huge UID/GIDs on i386
Summary: os.lstat() returns negative values for owner and/or group for huge UID/GIDs o...
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: python
Version: 6.0
Hardware: i386
OS: Unspecified
Target Milestone: rc
: ---
Assignee: Dave Malcolm
QA Contact: Petr Šplíchal
: 697472 (view as bug list)
Depends On:
Blocks: 682670 628730 849988
TreeView+ depends on / blocked
Reported: 2011-04-18 11:55 UTC by Eduard Benes
Modified: 2016-06-01 01:41 UTC (History)
6 users (show)

Fixed In Version: python-2.6.6-26.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 734844 849988 (view as bug list)
Last Closed: 2011-12-06 10:24:10 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:1564 0 normal SHIPPED_LIVE python bug fix and enhancement update 2011-12-06 00:39:12 UTC

Description Eduard Benes 2011-04-18 11:55:32 UTC
Description of problem:
os.lstat() returns negative values for owner and/or group for users with huge UID/GIDs on i386 arch while on other archs it is positive as expected and on i386 also libuser returns positive values. This is not a regression. 

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. # adduser -u 4294967293  foo
2. # python
>>> import os
>>> os.lstat('/home/foo/')
Actual results:
Negative UID -> st_uid=-3:
>>> os.lstat('/home/foo/')
posix.stat_result(st_mode=16832, st_ino=523265L, st_dev=64770L, st_nlink=4, st_uid=-3, st_gid=506, st_size=4096L, st_atime=1303126993, st_mtime=1303126936, st_ctime=1303126936)

Expected results:
Unchanged UID value ->  st_uid=4294967293:
>>> os.lstat('/home/foo/')
posix.stat_result(st_mode=16832, st_ino=16, st_dev=64771L, st_nlink=2, st_uid=4294967293, st_gid=502, st_size=1024, st_atime=1303126860, st_mtime=1303126860, st_ctime=1303126860)

Additional info:
The issue is causing failures in s-c-users on i386 systems when reproducing bug
https://bugzilla.redhat.com/show_bug.cgi?id=628730 but it might have also other negative implications.

Comment 1 Zbysek MRAZ 2011-04-18 12:16:30 UTC
*** Bug 697472 has been marked as a duplicate of this bug. ***

Comment 2 Dave Malcolm 2011-04-18 17:23:50 UTC
Relevant code is within Modules/posixmodule.c:

  1291  static PyObject*
  1292  _pystat_fromstructstat(STRUCT_STAT *st)
  1293  {
  1313      PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long)st->st_uid));
  1314      PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long)st->st_gid));

A PyIntObject can only hold a C "long" type, whereas as PyLongObject can hold an arbitrary-sized integer value.

Appears to still affect latest upstream 2.7 maintenance branch.
(Python 3 upstream uses PyLong_FromLong((long)st->st_uid) so may or may not be affected)

Comment 3 Dave Malcolm 2011-04-18 17:26:10 UTC
Looks similar to this upstream bug:

Comment 28 errata-xmlrpc 2011-12-06 10:24:10 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.