Skip to content

gh-137396: Raise InvalidHeaderError when offset or numbytes is negative #137805

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

moreal
Copy link
Contributor

@moreal moreal commented Aug 15, 2025

@@ -0,0 +1,2 @@
:func:`tarfile.Tarfile.fromtarfile` and :func:`tarfile.TarInfo.frombuf` raises
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/home/runner/work/cpython/cpython/Doc/build/NEWS:191: WARNING: py:func reference target not found: tarfile.Tarfile.fromtarfile [ref.func]

See docs CI failure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@corona10 I rewrote the NEWS file and it seems succeeded now.

The #137396 issue now has type-security label, then should I move the file to the Misc/NEWS.d/next/Security directory?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason why this fails is because fromtarfile is a classmethod of TarInfo not TarFile. Also, when referencing methods, it's better to use the meth role rather than the func one.

@moreal moreal marked this pull request as ready for review August 15, 2025 07:37
@moreal moreal requested a review from ethanfurman as a code owner August 15, 2025 07:37
@sethmlarson
Copy link
Contributor

Can we put guards around all values that we expect to be positive or zero? I'm thinking:

  • size
  • origsize
  • mtime (this one is actually called out in tar standard, time values must be positive).

@picnixz
Copy link
Member

picnixz commented Aug 18, 2025

Can we put guards around all values that we expect to be positive or zero? I'm thinking:

One way to do it is to add a flag to nti so that we raise a ValueError if the parsed value is negative, or to check all nti calls individually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants