Skip to content

Commit fed7792

Browse files
author
adam
committed
libarchive: imported version 3.8.6
1 parent 9f28c13 commit fed7792

10 files changed

Lines changed: 431 additions & 4 deletions

archivers/libarchive/files/contrib/oss-fuzz/libarchive_linkify_fuzzer.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,19 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
7676
// This is the main function we want to fuzz (zero coverage)
7777
archive_entry_linkify(resolver, &entry, &spare);
7878

79-
// entry and spare may be modified by linkify
80-
// We still need to free the original entries we allocated
79+
// Update entries[i] to reflect ownership changes from linkify.
80+
// If linkify cached the entry internally, entry is now NULL and the
81+
// resolver owns the object. If linkify swapped it with a previously
82+
// cached entry, entry points to that other object.
83+
entries[i] = entry;
84+
85+
// Free any entry returned via spare (complete hardlink pair)
8186
if (spare != NULL) {
8287
archive_entry_free(spare);
8388
}
8489
}
8590

86-
// Free remaining entries from the resolver
91+
// Free remaining entries from the resolver (drain loop)
8792
struct archive_entry *entry = NULL;
8893
struct archive_entry *spare = NULL;
8994
while (1) {
@@ -98,7 +103,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) {
98103
}
99104
}
100105

101-
// Free all our created entries
106+
// Free all our created entries that were NOT consumed by the resolver
102107
for (int i = 0; i < num_entries; i++) {
103108
if (entries[i] != NULL) {
104109
archive_entry_free(entries[i]);

archivers/libarchive/files/libarchive/test/test_acl_text.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,29 @@ DEFINE_TEST(test_acl_from_text)
404404
archive_entry_acl_clear(ae);
405405

406406
free(ws);
407+
408+
/*
409+
* 6. Malformed "default" prefix with no tag field should return
410+
* ARCHIVE_WARN, not crash (GitHub issue #2744).
411+
* When the ACL text is just "d" or "default" with type DEFAULT,
412+
* the parser recognises the default prefix but field[1] is NULL,
413+
* which previously caused a NULL-pointer dereference.
414+
*/
415+
archive_entry_acl_clear(ae);
416+
assertEqualInt(ARCHIVE_WARN,
417+
archive_entry_acl_from_text(ae, "d",
418+
ARCHIVE_ENTRY_ACL_TYPE_DEFAULT));
419+
assertEqualInt(ARCHIVE_WARN,
420+
archive_entry_acl_from_text_w(ae, L"d",
421+
ARCHIVE_ENTRY_ACL_TYPE_DEFAULT));
422+
archive_entry_acl_clear(ae);
423+
assertEqualInt(ARCHIVE_WARN,
424+
archive_entry_acl_from_text(ae, "default",
425+
ARCHIVE_ENTRY_ACL_TYPE_DEFAULT));
426+
assertEqualInt(ARCHIVE_WARN,
427+
archive_entry_acl_from_text_w(ae, L"default",
428+
ARCHIVE_ENTRY_ACL_TYPE_DEFAULT));
429+
407430
archive_entry_free(ae);
408431
}
409432

archivers/libarchive/files/libarchive/test/test_read_format_7zip_malformed.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,25 @@ test_malformed2(void)
5959
assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
6060
}
6161

62+
63+
static void
64+
test_malformed3(void)
65+
{
66+
const char *refname = "test_read_format_7zip_malformed3.7z";
67+
struct archive *a;
68+
69+
extract_reference_file(refname);
70+
71+
assert((a = archive_read_new()) != NULL);
72+
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
73+
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
74+
assertEqualIntA(a, ARCHIVE_FATAL, archive_read_open_filename(a, refname, 10240));
75+
assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
76+
}
77+
6278
DEFINE_TEST(test_read_format_7zip_malformed)
6379
{
6480
test_malformed1();
6581
test_malformed2();
82+
test_malformed3();
6683
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
begin 644 test_read_format_7zip_malformed3.7z
2+
M?T5,1@("`64N9&5B=0``+ZZNRO_______P```/\Q```````````"````````
3+
M```L0"!S+F)S,``1<P!```H``FMK__](:VMK:VNAH:$!`*&AH:&A)S$```!C
4+
M;VUP>FEP503_8G-S90``````#0H-_P```'X```````````(`````````````
5+
M`*D``````"\`````____^@````$````````#`/__________<RYD96)U```O
6+
MKJ[*________````_S$```````````(``````````"Q`(',N8G,P`!%S`$``
7+
M(``":VNAH2<Q```````#Z'K__P5%145%____________`/__________;VUP
8+
M>FEP503_8G-S90``````#0H-_P```'X```````````(``````````````*D`
9+
M`````"\`````____^@````$````````#_P```/______<RYD96)U```OKJ[*
10+
M________````_S$```````````(``````````"Q`(',N8G,P`!%S`$"0`P`"
11+
M:VLR:TAK:VMK:Z&AH0$`H:&AH:$G,@```&-O;7!Z:7!5!/]28W-E```````-
12+
M"@W_````?@```````````@``````````````J0``````+P`````0___Z````
13+
M`0````````,`__________\PXT$N9&%T80#^E)3+E)24_P3_____________
14+
M____(________^+______P5%145%____________`/__________________
15+
M_____________________^?_________145%0``#`/Z4E,N4P<'!P<'!E```
16+
M`/_R`````'5U=75U=75U=75U=75U=75U=75U=75U=75U=75U=75U=75U=75U
17+
M=75U=75U=75U=75U=75U=75U=75U=75U=75U=75U=75U=75U=0`````"````
18+
M```````L0"!S+F4```````T*#?\```!^```````````"``````````````"I
19+
M```````O`````/___^0````!`````````P#__W5U=75U=75U=75U=75U=75U
20+
M=0`````"```````````L0"!S+F)S,?P1<P!```,`"&MK,FM(:VMK145%145%
21+
,P45%145%1?____\$
22+
`
23+
end
24+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
begin 664 test_read_format_7zip_sfx_elf64trunc.elf
2+
M?T5,1@("````````````````````````````````````````````````````
3+
2```````````````````H``$`
4+
`
5+
end
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*-
2+
* Copyright (c) 2026 Tim Kientzle
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions
7+
* are met:
8+
* 1. Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* 2. Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the
12+
* documentation and/or other materials provided with the distribution.
13+
*
14+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17+
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
#include "test.h"
26+
27+
DEFINE_TEST(test_read_format_lha_oversize_header)
28+
{
29+
const char *refname = "test_read_format_lha_oversize_header.lzh";
30+
extract_reference_file(refname);
31+
struct archive_entry *ae;
32+
struct archive *a;
33+
34+
assert((a = archive_read_new()) != NULL);
35+
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
36+
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
37+
38+
assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 10240));
39+
40+
/* First 18 entries in the test file are well-formed */
41+
for (int i = 0; i < 18; i++) {
42+
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
43+
}
44+
45+
/* 19th has an oversized header */
46+
assertEqualInt(ARCHIVE_FATAL, archive_read_next_header(a, &ae));
47+
48+
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
49+
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
50+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
begin 644 test_read_format_lha_oversize_header.lzh
2+
M)L`M;&AD+0```````````$@B[!``!&1I<EP``%4`@5$!`.A!Z0/I`R?X+6QH
3+
M9"T```````````!((NP0``5D:7(R7```50"!40$`[4'I`^D#.'PM;&AD+0``
4+
M`````````4@C[!``%F1I<C)<<WEM;&EN:S%\+BY<9FEL93$``%4``J,"`.VA
5+
MZ0/I`SA^+6QH9"T```````````%((^P0`!9D:7(R7'-Y;6QI;FLR?"XN7&9I
6+
M;&4R``!5``*C`@#MH>D#Z0,GO2UL:#4M(@```#P`````2"+L(``%9FEL93&D
7+
MYU4`@5$!`*2!Z0/I`P`80FYIQ>/Z`=-:'>9%#"P%J!\CH0"/GE$,.W6FMSD%
8+
M*_4G02UL:#4M(@```$X`````2"+L(``%9FEL93+5%54`@5$!`+:!Z0/I`P`8
9+
M0FYIQV/Z`=.:'.9%#"P%J-\+H0"/'E$,.W6FMSD%*_T9?RUL:&0M&@``````
10+
M````2"+L(`$```!5!P`"9&ER_P4`4.A!!P!1Z0/I`P<`5(%1`0```!F!+6QH
11+
M9"T;``````````!((NP@`0```%4(``)D:7(R_P4`4.U!!P!1Z0/I`P<`5(%1
12+
M`0```!YQ+6QH9"TG``````````%((^P@`05F:6QE,0``510``F1I<C+_<WEM
13+
M;&EN:S%\+B[_!0!0[:$'`%'I`^D#!P!4`J,"````'G(M;&AD+2<`````````
14+
M`4@C["`!!69I;&4R``!5%``"9&ER,O]S>6UL:6YK,GPN+O\%`%#MH0<`4>D#
15+
MZ0,'`%0"HP(````>!BUL:#4M-0```#P`````2"+L(`$%9FEL93&DYU4%`%"D
16+
M@0<`4>D#Z0,'`%2!40$`````&$)N:<7C^@'36AWF10PL!:@?(Z$`CYY1##MU
17+
MIK<Y!2OU'G@M;&@U+34```!.`````$@B["`!!69I;&4RU155!0!0MH$'`%'I
18+
M`^D#!P!4@5$!`````!A";FG'8_H!TYH<YD4,+`6HWPNA`(\>40P[=::W.04K
19+
M_34`+6QH9"T``````````(%1`0`@`@``504```7>`P`!!P`"9&ER_P4`4.A!
20+
M!P!1Z0/I`P``-@`M;&AD+0``````````@5$!`"`"``!5!0``")D#``$(``)D
21+
M:7(R_P4`4.U!!P!1Z0/I`P``1P`M;&AD+0```````````J,"`"`"``!5!0``
22+
MM*D(``%F:6QE,10``F1I<C+_<WEM;&EN:S%\+B[_!0!0[:$'`%'I`^D#``!'
23+
M`"UL:&0M```````````"HP(`(`(``%4%``"'[0@``69I;&4R%``"9&ER,O]S
24+
M>6UL:6YK,GPN+O\%`%#MH0<`4>D#Z0,``#,`+6QH-2TB````/````(%1`0`@
25+
M`J3G504``/T!"``!9FEL93$%`%"D@0<`4>D#Z0,````80FYIQ>/Z`=-:'>9%
26+
M#"P%J!\CH0"/GE$,.W6FMSD%*_4S`"UL:#4M(@```$X```"!40$`(`+5%54%
27+
M```OQ@@``69I;&4R!0!0MH$'`%'I`^D#````&$)N:<=C^@'3FASF10PL!:C?
28+
M"Z$`CQY1##MUIK<Y!2O]!``M;&AD+0``````````@5$!`"`#``!-?/[___\`
29+
M````````````````````````````````````````````````````````````
30+
M`````````````````````````````````````$:D`P``!0````$)`````F1I
31+
M<O\'````0!``&0```/_M00`````````````,%?Y,1!K^3!T```!!S-]1M/Z5
32+
MRP&`UD``J+*=`0!Z#]`!ELL!"``````NKP<`````!``M;&AD+0``````````
33+
M@5$!`"`#``!-?0````D```!&I`,```4````!"@````)D:7(R_P<```!`$``9
34+
M````_^U!`````````````"$:_DQ$&OY,'0```$%*@6Z[`9;+`8#60`"HLIT!
35+
M`'H/T`&6RP$(`````'T7!P`````$`"UL:#4M)````#P```"!40$`(`.DYTUQ
36+
M````"0```$:D`P``"@````%F:6QE,1D```#_I($`````````````QQ3^3",:
37+
M_DP=````031"HHK^E<L!@-9``*BRG0'^<J2\`9;+`0@`````"O$'```````9
38+
M0FV1J+1V@'IK0ZGID/-H#J@6.H0"'V^-&353:F^XA-UZ@`0`+6QH-2TD````
39+
M3@```(%1`0`@`]4537$````)````1J0#```*`````69I;&4R&0```/^D@0``
40+
M```````````A&OY,(QK^3!T```!!_D5SNP&6RP&`UD``J+*=`5C5IKP!ELL!
41+
M"`````!!W@<``````!E";9&H[':`>G-#B>F0\V@.J,8:A`(>;XT9-5-J;[B$
42+
MW7Z`-0`M;&AD+0``````````@5$!`"`"``!5!40:_DP=````0<S?4;3^E<L!
43+
M@-9``*BRG0$`>@_0`9;+`0@`````+J\'``````0`+6QH9"T``````````(%1
44+
M`0`@`P``37T````)````1J0#```%`````0H````"9&ER,O\'````0!``&0``
45+
M`/_M00`````````````A&OY,1!K^3!T```!!2H%NNP&6RP&`UD``J+*=`0!Z
46+
M#]`!ELL!"`````!]%P<`````!``M;&@U+20````\````@5$!`"`#I.=-<0``
47+
M``D```!&I`,```H````!9FEL93$9````_Z2!`````````````,<4_DPC&OY,
48+
M'0```$$T0J**_I7+`8#60`"HLIT!_G*DO`&6RP$(``````KQ!P``````&4)M
49+
MD:BT=H!Z:T.IZ9!1Z0/I`P```FUK=XVV['"Z\`>$(6[`2-EZ5P&P^!J*0MPV
50+
M*IM]&^L37/)<Y+,0WC;RYN647;X'R_\P`E;2>[SD(6GCE`4$+,RA<%QVYXC%
51+
M'H1Q`I@_B\H/L@(+W3`0@5CY6X%Q%WW+@7<`8(F7=77U]%5YG?`;3N&I:_6Y
52+
MWA$,3F@?:)>FZ!<!"?.:#C/:',\PG@>:WRP0:TH8%&:/A#VMNUUD[D?+:#XK
53+
M%3NMR(PSF4;V"^\X0/E3JMRQ46+7\I]S@7ZJNTX[ROSD+=\7\.O#I:W._S>P
54+
M-B(W4`=N<T/$OT+5];U>*!<4AM0Y4$L'"(=02P,$\$*.O%TM;&@U+0``KPLX
55+
M+4``2@````````"``````/________\`````````V0````"A````````````
56+
M````````````+6QH-RT```!8$,P.0&OJER*:CF[S6/=2*T4J8HB@[:HP^'7*
57+
MK?(\7:Y+-"U'*^OXT210`,J%*>9(T9[(@N(DJ+A)A```3`]%Z8U.^3!F0_G-
58+
17YFUYB_%6DWMSZ8'\Z-^CR@`
59+
`
60+
end
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*-
2+
* Copyright (c) 2026 Tim Kientzle
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions
7+
* are met:
8+
* 1. Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* 2. Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the
12+
* documentation and/or other materials provided with the distribution.
13+
*
14+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17+
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
#include "test.h"
26+
27+
DEFINE_TEST(test_read_format_rar5_loop_bug)
28+
{
29+
const char *reffile = "test_read_format_rar5_loop_bug.rar";
30+
struct archive_entry *ae;
31+
struct archive *a;
32+
const void *buf;
33+
size_t size;
34+
la_int64_t offset;
35+
36+
extract_reference_file(reffile);
37+
assert((a = archive_read_new()) != NULL);
38+
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
39+
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
40+
assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, reffile, 10240));
41+
42+
// This has just one entry
43+
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
44+
45+
// Read blocks until the end of the entry
46+
while (ARCHIVE_OK == archive_read_data_block(a, &buf, &size, &offset)) {
47+
}
48+
49+
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
50+
51+
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
52+
assertEqualInt(ARCHIVE_OK, archive_free(a));
53+
}

0 commit comments

Comments
 (0)