aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/zip.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2017-02-27 15:46:58 +0100
committerBjörn Gustavsson <[email protected]>2017-02-28 09:52:27 +0100
commit45a64bda7c605bb5effca0085e9df6f56ddba24a (patch)
treeff571f6f7fad1bb0dd0785fc9bca7fcb40718dc3 /lib/stdlib/src/zip.erl
parent87d87c57841dc7a295b3e74f807198e34df4adb4 (diff)
downloadotp-45a64bda7c605bb5effca0085e9df6f56ddba24a.tar.gz
otp-45a64bda7c605bb5effca0085e9df6f56ddba24a.tar.bz2
otp-45a64bda7c605bb5effca0085e9df6f56ddba24a.zip
zip: Don't crash when a zip file has an Unix extra header
There is unfinished code in the zip module to handle the extra field in the central-directory header for each file. The code to extract an Unix extra subfield is incorrect and always causes a bad_unix_extra_field error. A further flaw in the code is that it expects that there is only a single subfield. Correcting the code for extracting extra subfields will not do any good, because the extracted data is ignored. In fact, not even the file times extracted from DOS file times are used for some reason. Therefore, don't correct the unfinished code. Remove it completely. (If needed, extending zip to use file times and to use the information in the extra field should be done in a major release, not in a maintenance release.) ERL-348
Diffstat (limited to 'lib/stdlib/src/zip.erl')
-rw-r--r--lib/stdlib/src/zip.erl34
1 files changed, 1 insertions, 33 deletions
diff --git a/lib/stdlib/src/zip.erl b/lib/stdlib/src/zip.erl
index 340cc21390..31438ae36b 100644
--- a/lib/stdlib/src/zip.erl
+++ b/lib/stdlib/src/zip.erl
@@ -179,19 +179,6 @@
external_attr,
local_header_offset}).
-%% Unix extra fields (not yet supported)
--define(UNIX_EXTRA_FIELD_TAG, 16#000d).
--record(unix_extra_field, {atime,
- mtime,
- uid,
- gid}).
-
-%% extended timestamps (not yet supported)
--define(EXTENDED_TIMESTAMP_TAG, 16#5455).
-%% -record(extended_timestamp, {mtime,
-%% atime,
-%% ctime}).
-
-define(END_OF_CENTRAL_DIR_MAGIC, 16#06054b50).
-define(END_OF_CENTRAL_DIR_SZ, (4+2+2+2+2+4+4+2)).
@@ -1379,12 +1366,7 @@ cd_file_header_to_file_info(FileName,
gid = 0},
add_extra_info(FI, ExtraField).
-%% add extra info to file (some day when we implement it)
-add_extra_info(FI, <<?EXTENDED_TIMESTAMP_TAG:16/little, _Rest/binary>>) ->
- FI; % not yet supported, some other day...
-add_extra_info(FI, <<?UNIX_EXTRA_FIELD_TAG:16/little, Rest/binary>>) ->
- _UnixExtra = unix_extra_field_and_var_from_bin(Rest),
- FI; % not yet supported, and not widely used
+%% Currently, we ignore all the extra fields.
add_extra_info(FI, _) ->
FI.
@@ -1572,20 +1554,6 @@ dos_date_time_from_datetime({{Year, Month, Day}, {Hour, Min, Sec}}) ->
<<DosDate:16>> = <<YearFrom1980:7, Month:4, Day:5>>,
{DosDate, DosTime}.
-unix_extra_field_and_var_from_bin(<<TSize:16/little,
- ATime:32/little,
- MTime:32/little,
- UID:16/little,
- GID:16/little,
- Var:TSize/binary>>) ->
- {#unix_extra_field{atime = ATime,
- mtime = MTime,
- uid = UID,
- gid = GID},
- Var};
-unix_extra_field_and_var_from_bin(_) ->
- throw(bad_unix_extra_field).
-
%% A pwrite-like function for iolists (used by memory-option)
pwrite_binary(B, Pos, Bin) when byte_size(B) =:= Pos ->