Skip to content

tarfile cannot handle high UIDs such as 734_380_696 (or at least the test fails) #101334

Closed
@gpshead

Description

@gpshead

Run test_tarfile on a posix system as a user with a high userid such as 734380696 and test_add_dir_getmember will fail with:

ERROR: test_add_dir_getmember (test.test_tarfile.Bz2UstarReadTest.test_add_dir_getmember)                                    
----------------------------------------------------------------------                                                       
Traceback (most recent call last):                                                                                           
  File "/.../cpython/Lib/test/test_tarfile.py", line 225, in test_add_dir_getmember                      
    self.add_dir_and_getmember('bar')                                                                                        
  File "/.../cpython/Lib/test/test_tarfile.py", line 234, in add_dir_and_getmember                       
    tar.add(name)                                                                                                            
  File "/.../cpython/Lib/tarfile.py", line 2001, in add                                                  
    self.addfile(tarinfo)                                                                                                    
  File "/.../cpython/Lib/tarfile.py", line 2020, in addfile                                              
    buf = tarinfo.tobuf(self.format, self.encoding, self.errors)                                                             
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                             
  File "/.../cpython/Lib/tarfile.py", line 823, in tobuf                                                 
    return self.create_ustar_header(info, encoding, errors)                                                                  
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                  
  File "/.../cpython/Lib/tarfile.py", line 842, in create_ustar_header                                   
    return self._create_header(info, USTAR_FORMAT, encoding, errors)                                                         
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                         
  File "/.../cpython/Lib/tarfile.py", line 954, in _create_header                                        
    itn(info.get("uid", 0), 8, format),                                                                                      
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                       
  File "/.../cpython/Lib/tarfile.py", line 214, in itn                                                   
    raise ValueError("overflow in number field")                                                                             
ValueError: overflow in number field               

Linked PRs

Metadata

Metadata

Assignees

Labels

stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions