Skip to content

Commit 30b2fe2

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents a88b03d + 13c710a commit 30b2fe2

32 files changed

+2320
-899
lines changed

CMakeLists.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,6 @@ LA_CHECK_INCLUDE_FILE("sys/mkdev.h" HAVE_SYS_MKDEV_H)
743743
LA_CHECK_INCLUDE_FILE("sys/mount.h" HAVE_SYS_MOUNT_H)
744744
LA_CHECK_INCLUDE_FILE("sys/param.h" HAVE_SYS_PARAM_H)
745745
LA_CHECK_INCLUDE_FILE("sys/poll.h" HAVE_SYS_POLL_H)
746-
LA_CHECK_INCLUDE_FILE("sys/queue.h" HAVE_SYS_QUEUE_H)
747746
LA_CHECK_INCLUDE_FILE("sys/richacl.h" HAVE_SYS_RICHACL_H)
748747
LA_CHECK_INCLUDE_FILE("sys/select.h" HAVE_SYS_SELECT_H)
749748
LA_CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
@@ -2174,6 +2173,11 @@ IF(APPLE)
21742173
ADD_DEFINITIONS(-Wno-deprecated-declarations)
21752174
ENDIF(APPLE)
21762175

2176+
OPTION(DONT_FAIL_ON_CRC_ERROR "Ignore CRC errors during parsing (For fuzzing)" OFF)
2177+
IF(DONT_FAIL_ON_CRC_ERROR)
2178+
ADD_DEFINITIONS(-DDONT_FAIL_ON_CRC_ERROR=1)
2179+
ENDIF(DONT_FAIL_ON_CRC_ERROR)
2180+
21772181
IF(ENABLE_TEST)
21782182
ADD_CUSTOM_TARGET(run_all_tests)
21792183
ENDIF(ENABLE_TEST)

Makefile.am

+4
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ libarchive_test_SOURCES= \
522522
libarchive/test/test_read_format_tar_empty_with_gnulabel.c \
523523
libarchive/test/test_read_format_tar_filename.c \
524524
libarchive/test/test_read_format_tar_invalid_pax_size.c \
525+
libarchive/test/test_read_format_tar_pax_large_attr.c \
525526
libarchive/test/test_read_format_tbz.c \
526527
libarchive/test/test_read_format_tgz.c \
527528
libarchive/test/test_read_format_tlz.c \
@@ -832,6 +833,7 @@ libarchive_test_EXTRA_DIST=\
832833
libarchive/test/test_read_format_huge_rpm.rpm.uu \
833834
libarchive/test/test_read_format_iso.iso.Z.uu \
834835
libarchive/test/test_read_format_iso_2.iso.Z.uu \
836+
libarchive/test/test_read_format_iso_3.iso.Z.uu \
835837
libarchive/test/test_read_format_iso_joliet.iso.Z.uu \
836838
libarchive/test/test_read_format_iso_joliet_by_nero.iso.Z.uu \
837839
libarchive/test/test_read_format_iso_joliet_long.iso.Z.uu \
@@ -932,11 +934,13 @@ libarchive_test_EXTRA_DIST=\
932934
libarchive/test/test_read_format_tar_empty_pax.tar.Z.uu \
933935
libarchive/test/test_read_format_tar_filename_koi8r.tar.Z.uu \
934936
libarchive/test/test_read_format_tar_invalid_pax_size.tar.uu \
937+
libarchive/test/test_read_format_tar_pax_large_attr.tar.Z.uu \
935938
libarchive/test/test_read_format_ustar_filename_cp866.tar.Z.uu \
936939
libarchive/test/test_read_format_ustar_filename_eucjp.tar.Z.uu \
937940
libarchive/test/test_read_format_ustar_filename_koi8r.tar.Z.uu \
938941
libarchive/test/test_read_format_warc.warc.uu \
939942
libarchive/test/test_read_format_xar_doublelink.xar.uu \
943+
libarchive/test/test_read_format_xar_duplicate_filename_node.xar.uu \
940944
libarchive/test/test_read_format_zip.zip.uu \
941945
libarchive/test/test_read_format_zip_7075_utf8_paths.zip.uu \
942946
libarchive/test/test_read_format_zip_7z_deflate.zip.uu \

build/cmake/config.h.in

-3
Original file line numberDiff line numberDiff line change
@@ -1132,9 +1132,6 @@ typedef uint64_t uintmax_t;
11321132
/* Define to 1 if you have the <sys/poll.h> header file. */
11331133
#cmakedefine HAVE_SYS_POLL_H 1
11341134

1135-
/* Define to 1 if you have the <sys/queue.h> header file. */
1136-
#cmakedefine HAVE_SYS_QUEUE_H 1
1137-
11381135
/* Define to 1 if you have the <sys/richacl.h> header file. */
11391136
#cmakedefine HAVE_SYS_RICHACL_H 1
11401137

configure.ac

+3-4
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ AC_PROG_CC
113113
AM_PROG_CC_C_O
114114
AC_PROG_CPP
115115
AC_USE_SYSTEM_EXTENSIONS
116-
AC_LIBTOOL_WIN32_DLL
117-
AC_PROG_LIBTOOL
116+
117+
LT_INIT([win32-dll])
118118
AC_CHECK_TOOL([STRIP],[strip])
119119
AC_PROG_MKDIR_P
120120

@@ -362,7 +362,7 @@ AC_CHECK_HEADERS([locale.h membership.h paths.h poll.h pthread.h pwd.h])
362362
AC_CHECK_HEADERS([readpassphrase.h signal.h spawn.h])
363363
AC_CHECK_HEADERS([stdarg.h stdint.h stdlib.h string.h])
364364
AC_CHECK_HEADERS([sys/acl.h sys/cdefs.h sys/ea.h sys/extattr.h])
365-
AC_CHECK_HEADERS([sys/ioctl.h sys/mkdev.h sys/mount.h sys/queue.h])
365+
AC_CHECK_HEADERS([sys/ioctl.h sys/mkdev.h sys/mount.h])
366366
AC_CHECK_HEADERS([sys/param.h sys/poll.h sys/richacl.h])
367367
AC_CHECK_HEADERS([sys/select.h sys/statfs.h sys/statvfs.h sys/sysmacros.h])
368368
AC_CHECK_HEADERS([sys/time.h sys/utime.h sys/utsname.h sys/vfs.h sys/xattr.h])
@@ -777,7 +777,6 @@ AX_COMPILE_CHECK_SIZEOF(long)
777777
AC_CHECK_HEADERS_ONCE([sys/time.h])
778778

779779
# Checks for library functions.
780-
AC_PROG_GCC_TRADITIONAL
781780
AC_HEADER_MAJOR
782781
AC_FUNC_FSEEKO
783782
AC_FUNC_MEMCMP

cpio/test/test_option_t.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ DEFINE_TEST(test_option_t)
8989
mtime = 1;
9090
#ifdef HAVE_LOCALE_H
9191
setlocale(LC_ALL, "");
92+
setlocale(LC_TIME, "");
9293
#endif
9394
#if defined(HAVE_LOCALTIME_S)
9495
tmptr = localtime_s(&tmbuf, &mtime) ? NULL : &tmbuf;
@@ -99,10 +100,10 @@ DEFINE_TEST(test_option_t)
99100
#endif
100101
#if defined(_WIN32) && !defined(__CYGWIN__)
101102
strftime(date2, sizeof(date2)-1, "%b %d %Y", tmptr);
102-
_snprintf(date, sizeof(date)-1, "%12.12s file", date2);
103+
_snprintf(date, sizeof(date)-1, "%12s file", date2);
103104
#else
104105
strftime(date2, sizeof(date2)-1, "%b %e %Y", tmptr);
105-
snprintf(date, sizeof(date)-1, "%12.12s file", date2);
106+
snprintf(date, sizeof(date)-1, "%12s file", date2);
106107
#endif
107108
assertEqualMem(p + 42, date, strlen(date));
108109
free(p);

libarchive/archive_acl.c

+29-22
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ static int is_nfs4_flags(const char *start, const char *end,
7676
int *result);
7777
static int is_nfs4_perms(const char *start, const char *end,
7878
int *result);
79-
static void next_field(const char **p, const char **start,
79+
static void next_field(const char **p, size_t *l, const char **start,
8080
const char **end, char *sep);
8181
static void append_entry(char **p, const char *prefix, int type,
8282
int tag, int flags, const char *name, int perm, int id);
@@ -1619,6 +1619,13 @@ next_field_w(const wchar_t **wp, const wchar_t **start,
16191619
int
16201620
archive_acl_from_text_l(struct archive_acl *acl, const char *text,
16211621
int want_type, struct archive_string_conv *sc)
1622+
{
1623+
return archive_acl_from_text_nl(acl, text, strlen(text), want_type, sc);
1624+
}
1625+
1626+
int
1627+
archive_acl_from_text_nl(struct archive_acl *acl, const char *text,
1628+
size_t length, int want_type, struct archive_string_conv *sc)
16221629
{
16231630
struct {
16241631
const char *start;
@@ -1649,15 +1656,15 @@ archive_acl_from_text_l(struct archive_acl *acl, const char *text,
16491656
ret = ARCHIVE_OK;
16501657
types = 0;
16511658

1652-
while (text != NULL && *text != '\0') {
1659+
while (text != NULL && length > 0 && *text != '\0') {
16531660
/*
16541661
* Parse the fields out of the next entry,
16551662
* advance 'text' to start of next entry.
16561663
*/
16571664
fields = 0;
16581665
do {
16591666
const char *start, *end;
1660-
next_field(&text, &start, &end, &sep);
1667+
next_field(&text, &length, &start, &end, &sep);
16611668
if (fields < numfields) {
16621669
field[fields].start = start;
16631670
field[fields].end = end;
@@ -2047,50 +2054,50 @@ is_nfs4_flags(const char *start, const char *end, int *permset)
20472054
}
20482055

20492056
/*
2050-
* Match "[:whitespace:]*(.*)[:whitespace:]*[:,\n]". *wp is updated
2057+
* Match "[:whitespace:]*(.*)[:whitespace:]*[:,\n]". *p is updated
20512058
* to point to just after the separator. *start points to the first
20522059
* character of the matched text and *end just after the last
20532060
* character of the matched identifier. In particular *end - *start
20542061
* is the length of the field body, not including leading or trailing
20552062
* whitespace.
20562063
*/
20572064
static void
2058-
next_field(const char **p, const char **start,
2065+
next_field(const char **p, size_t *l, const char **start,
20592066
const char **end, char *sep)
20602067
{
20612068
/* Skip leading whitespace to find start of field. */
2062-
while (**p == ' ' || **p == '\t' || **p == '\n') {
2069+
while (*l > 0 && (**p == ' ' || **p == '\t' || **p == '\n')) {
20632070
(*p)++;
2071+
(*l)--;
20642072
}
20652073
*start = *p;
20662074

2067-
/* Scan for the separator. */
2068-
while (**p != '\0' && **p != ',' && **p != ':' && **p != '\n' &&
2069-
**p != '#') {
2075+
/* Locate end of field, trim trailing whitespace if necessary */
2076+
while (*l > 0 && **p != ' ' && **p != '\t' && **p != '\n' && **p != ',' && **p != ':' && **p != '#') {
20702077
(*p)++;
2078+
(*l)--;
20712079
}
2072-
*sep = **p;
2080+
*end = *p;
20732081

2074-
/* Locate end of field, trim trailing whitespace if necessary */
2075-
if (*p == *start) {
2076-
*end = *p;
2077-
} else {
2078-
*end = *p - 1;
2079-
while (**end == ' ' || **end == '\t' || **end == '\n') {
2080-
(*end)--;
2081-
}
2082-
(*end)++;
2082+
/* Scan for the separator. */
2083+
while (*l > 0 && **p != ',' && **p != ':' && **p != '\n' && **p != '#') {
2084+
(*p)++;
2085+
(*l)--;
20832086
}
2087+
*sep = **p;
20842088

20852089
/* Handle in-field comments */
20862090
if (*sep == '#') {
2087-
while (**p != '\0' && **p != ',' && **p != '\n') {
2091+
while (*l > 0 && **p != ',' && **p != '\n') {
20882092
(*p)++;
2093+
(*l)--;
20892094
}
20902095
*sep = **p;
20912096
}
20922097

2093-
/* Adjust scanner location. */
2094-
if (**p != '\0')
2098+
/* Skip separator. */
2099+
if (*l > 0) {
20952100
(*p)++;
2101+
(*l)--;
2102+
}
20962103
}

libarchive/archive_acl_private.h

+2
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,7 @@ int archive_acl_from_text_w(struct archive_acl *, const wchar_t * /* wtext */,
7777
int /* type */);
7878
int archive_acl_from_text_l(struct archive_acl *, const char * /* text */,
7979
int /* type */, struct archive_string_conv *);
80+
int archive_acl_from_text_nl(struct archive_acl *, const char * /* text */,
81+
size_t /* size of text */, int /* type */, struct archive_string_conv *);
8082

8183
#endif /* ARCHIVE_ENTRY_PRIVATE_H_INCLUDED */

0 commit comments

Comments
 (0)