Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gpshead opened this issue Jan 26, 2023 · 3 comments
Closed
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@gpshead
Copy link
Member

gpshead commented Jan 26, 2023

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

@gpshead gpshead added type-bug An unexpected behavior, bug, or error stdlib Python modules in the Lib dir labels Jan 26, 2023
@gpshead
Copy link
Member Author

gpshead commented Jan 27, 2023

I added a buildbot using a high uid and gid. https://buildbot.python.org/all/#/builders/1084 will show the error.

gpshead added a commit to gpshead/cpython that referenced this issue Feb 5, 2023
That causes the test to fail when run using a high UID as that ancient format
cannot represent it. The current default (PAX) and the old default (GNU) both
support high UIDs.
@gpshead
Copy link
Member Author

gpshead commented Feb 5, 2023

I believe this is a test problem, test_tarfile's add_dir_and_getmember explicitly sets USTAR_FORMAT.

@gpshead gpshead self-assigned this Feb 5, 2023
ethanfurman pushed a commit that referenced this issue Feb 5, 2023
That causes the test to fail when run using a high UID as that ancient format
cannot represent it. The current default (PAX) and the old default (GNU) both
support high UIDs.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Feb 5, 2023
…101572)

That causes the test to fail when run using a high UID as that ancient format
cannot represent it. The current default (PAX) and the old default (GNU) both
support high UIDs.
(cherry picked from commit ffcb822)

Co-authored-by: Gregory P. Smith <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Feb 5, 2023
…101572)

That causes the test to fail when run using a high UID as that ancient format
cannot represent it. The current default (PAX) and the old default (GNU) both
support high UIDs.
(cherry picked from commit ffcb822)

Co-authored-by: Gregory P. Smith <[email protected]>
miss-islington added a commit that referenced this issue Feb 5, 2023
That causes the test to fail when run using a high UID as that ancient format
cannot represent it. The current default (PAX) and the old default (GNU) both
support high UIDs.
(cherry picked from commit ffcb822)

Co-authored-by: Gregory P. Smith <[email protected]>
miss-islington added a commit that referenced this issue Feb 5, 2023
That causes the test to fail when run using a high UID as that ancient format
cannot represent it. The current default (PAX) and the old default (GNU) both
support high UIDs.
(cherry picked from commit ffcb822)

Co-authored-by: Gregory P. Smith <[email protected]>
@gpshead
Copy link
Member Author

gpshead commented Feb 5, 2023

confirmed, this fixed the problem. https://buildbot.python.org/all/#/workers/60

@gpshead gpshead closed this as completed Feb 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant