Skip to content
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

bpo-29612 : Fix hard link creation in tar extraction when it points to themselves #5753

Closed
wants to merge 10,000 commits into from

Conversation

j0ack
Copy link

@j0ack j0ack commented Feb 19, 2018

When creating a link from a tarball, if the link target and the file has the same path it raised an exception.

We simply ignore this case at the beginning of the method.

https://bugs.python.org/issue29612

@j0ack j0ack changed the title [2.7] Fix hard link creation in tar extraction when it points to themselves (GH-29612) [2.7] Fix hard link creation in tar extraction when it points to themselves (bpo-29612) Feb 19, 2018
@j0ack j0ack changed the title [2.7] Fix hard link creation in tar extraction when it points to themselves (bpo-29612) [2.7] bpo-29612 : Fix hard link creation in tar extraction when it points to themselves Feb 21, 2018
@j0ack j0ack force-pushed the bpo-29612 branch 2 times, most recently from 5aa1a9f to bb9e23c Compare Feb 23, 2018
Lib/tarfile.py Outdated
@@ -2272,6 +2272,13 @@ def makelink(self, tarinfo, targetpath):
(platform limitation), we try to make a copy of the referenced file
instead of a link.
"""
# do not create link if target path is equals to link target
if (
Copy link
Member

@matrixise matrixise Mar 28, 2018

Choose a reason for hiding this comment

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

could you use the PEP8 style for the condition?
for example

if hasattr(tarinfo, "_link_target") and tarinfo._link_target == targetpath:

Copy link
Author

@j0ack j0ack Mar 28, 2018

Choose a reason for hiding this comment

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

The line is 83 characters long if I do not split it into two lines.

Copy link
Sponsor Member

@Mariatta Mariatta Mar 28, 2018

Choose a reason for hiding this comment

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

The preferred way to split it is as follows:

if hasattr(tarinfo, "_link_target") and \
    tarinfo._link_target == targetpath:

Copy link
Member

@matrixise matrixise left a comment

review the style for the condition

@j0ack
Copy link
Author

j0ack commented Mar 28, 2018

done

When I do not split the condition into two lines, the result is 83 characters long, which is not pep8 right ?

@matrixise
Copy link
Member

matrixise commented Mar 28, 2018

@j0ack not necessarily, the max length can be between 80 and 100, check the PEP8 https://www.python.org/dev/peps/pep-0008/#maximum-line-length

@encukou
Copy link
Member

encukou commented Mar 28, 2018

That document says:

The Python standard library is conservative and requires limiting lines to 79 characters (and docstrings/comments to 72).

So, yes, 83 characters is too long.

@j0ack
Copy link
Author

j0ack commented Mar 29, 2018

That's the reason why I splitted my condition into two lines.

Let me know if I need to revert to my previous commit

I can reduce the line length with getattr default parameter

@j0ack j0ack force-pushed the bpo-29612 branch 2 times, most recently from 39194c2 to f4eb463 Compare Mar 29, 2018
@j0ack
Copy link
Author

j0ack commented Apr 6, 2018

Travis seems to fail on test_imaplib on clang but I did not modify any C code. This test seems not related to the PR.

twisteroidambassador and others added 11 commits Jun 27, 2018
…7968)

test_mymanager_context() now also accepts -SIGTERM as an expected
exitcode for the manager process. The process is killed with SIGTERM
if it takes longer than 1 second to stop.
bpo-30339, bpo-33913:

* Increase timeout from 10 seconds to 1 minute in
  test_source_main_skipped_in_children source of
  test_multiprocessing_main_handling.
* Replace time.time() with time.monotonic().
* On timeout, include the duration in the error message.
Increase timeouts from 10 seconds to 1 minute.
lysnikolaou and others added 3 commits Aug 3, 2018
Rephrase it to "It raises a `ValueError`"
Some MacOS-tk combinations need .update_idletasks().
The call is both unneeded and innocuous on Linux and Windows.
Patch by Kevin Waltzer.
Remove unnecessary "that" in the sentence.
methane and others added 12 commits Aug 3, 2018
sys_setcheckinterval() now uses a local variable to parse arguments,
before writing into interp->check_interval.
…'t support them. (pythonGH-8656)

When the filesystem doesn't support files with large timestamps,
skip testing that such files can be zipped.
…GH-8658)

If coerce_c_locale is already set (>= 0), use its value: don't
override it.
bpo-34170, bpo-34326: Fix pymain_run_file(): use
PyRun_AnyFileExFlags(closeit=1) instead of calling fclose(fp)
explicitly to close the input file before running the code.
…sts (pythonGH-7683)

* make CallTip and ToolTip sub-classes of a common abstract base class
* remove ListboxToolTip (unused and ugly)
* greatly increase test coverage
* tested on Windows, Linux and macOS
* bpo-34273: Change 'Fixed point' to 'Fixed-point notation'.
The change in the mini language floating point and decimal table
is consistent with 'Exponential notation' and clarifies that we
are referring to the output notation, not an object type.

* Update string.rst

* Update string.rst

* Update string.rst

* Update string.rst
@j0ack j0ack changed the title [2.7] bpo-29612 : Fix hard link creation in tar extraction when it points to themselves bpo-29612 : Fix hard link creation in tar extraction when it points to themselves Aug 6, 2018
@JulienPalard
Copy link
Member

JulienPalard commented Aug 6, 2018

@j0ack will try to commit this to master first then backport it to 2.7.

@j0ack
Copy link
Author

j0ack commented Aug 7, 2018

See #8700

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.

None yet