Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
9133ecf5
Commit
9133ecf5
authored
Oct 24, 2006
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch [ 1583506 ] tarfile.py: 100-char filenames are truncated
parent
e1d8f276
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletion
+28
-1
Lib/tarfile.py
Lib/tarfile.py
+1
-1
Lib/test/test_tarfile.py
Lib/test/test_tarfile.py
+27
-0
No files found.
Lib/tarfile.py
View file @
9133ecf5
...
...
@@ -136,7 +136,7 @@ TOEXEC = 0001 # execute/search by other
def
stn
(
s
,
length
):
"""Convert a python string to a null-terminated string buffer.
"""
return
s
[:
length
-
1
]
+
(
length
-
len
(
s
)
-
1
)
*
NUL
+
NUL
return
s
[:
length
]
+
(
length
-
len
(
s
))
*
NUL
def
nti
(
s
):
"""Convert a number field to a python number.
...
...
Lib/test/test_tarfile.py
View file @
9133ecf5
...
...
@@ -280,6 +280,32 @@ class WriteTest(BaseTest):
else
:
self
.
dst
.
addfile
(
tarinfo
,
f
)
class
Write100Test
(
BaseTest
):
# The name field in a tar header stores strings of at most 100 chars.
# If a string is shorter than 100 chars it has to be padded with '\0',
# which implies that a string of exactly 100 chars is stored without
# a trailing '\0'.
def
setUp
(
self
):
self
.
name
=
"01234567890123456789012345678901234567890123456789"
self
.
name
+=
"01234567890123456789012345678901234567890123456789"
self
.
tar
=
tarfile
.
open
(
tmpname
(),
"w"
)
t
=
tarfile
.
TarInfo
(
self
.
name
)
self
.
tar
.
addfile
(
t
)
self
.
tar
.
close
()
self
.
tar
=
tarfile
.
open
(
tmpname
())
def
tearDown
(
self
):
self
.
tar
.
close
()
def
test
(
self
):
self
.
assertEqual
(
self
.
tar
.
getnames
()[
0
],
self
.
name
,
"failed to store 100 char filename"
)
class
WriteSize0Test
(
BaseTest
):
mode
=
'w'
...
...
@@ -623,6 +649,7 @@ def test_main():
ReadAsteriskTest
,
ReadStreamAsteriskTest
,
WriteTest
,
Write100Test
,
WriteSize0Test
,
WriteStreamTest
,
WriteGNULongTest
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment