diff options
author | mm <mm@FreeBSD.org> | 2016-10-12 10:28:54 +0000 |
---|---|---|
committer | mm <mm@FreeBSD.org> | 2016-10-12 10:28:54 +0000 |
commit | 46874a6250923b10e7c7b672f1b558ae71dd2316 (patch) | |
tree | 8fb4e472aa4235d9a6b5200afc81aad5cab06534 /contrib/libarchive/cat | |
parent | 9b1acc28aaf1ed0563be0a7c99248ea66e22ad38 (diff) | |
download | FreeBSD-src-46874a6250923b10e7c7b672f1b558ae71dd2316.zip FreeBSD-src-46874a6250923b10e7c7b672f1b558ae71dd2316.tar.gz |
MFC r306670:
Sync libarchive with vendor including security fixes.
Important vendor bugfixes (relevant to FreeBSD):
#747: Out of bounds read in mtree parser
#761: heap-based buffer overflow in read_Header (7-zip)
#794: Invalid file on bsdtar command line results in internal errors (1)
PR: 213092 (1)
Diffstat (limited to 'contrib/libarchive/cat')
-rw-r--r-- | contrib/libarchive/cat/test/main.c | 39 | ||||
-rw-r--r-- | contrib/libarchive/cat/test/test.h | 1 |
2 files changed, 38 insertions, 2 deletions
diff --git a/contrib/libarchive/cat/test/main.c b/contrib/libarchive/cat/test/main.c index 0aa1deb..29f7b14 100644 --- a/contrib/libarchive/cat/test/main.c +++ b/contrib/libarchive/cat/test/main.c @@ -1360,6 +1360,31 @@ assertion_file_birthtime_recent(const char *file, int line, return assertion_file_time(file, line, pathname, 0, 0, 'b', 1); } +/* Verify mode of 'pathname'. */ +int +assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode) +{ + int mode; + int r; + + assertion_count(file, line); +#if defined(_WIN32) && !defined(__CYGWIN__) + failure_start(file, line, "assertFileMode not yet implemented for Windows"); +#else + { + struct stat st; + r = lstat(pathname, &st); + mode = (int)(st.st_mode & 0777); + } + if (r == 0 && mode == expected_mode) + return (1); + failure_start(file, line, "File %s has mode %o, expected %o", + pathname, mode, expected_mode); +#endif + failure_finish(NULL); + return (0); +} + /* Verify mtime of 'pathname'. */ int assertion_file_mtime(const char *file, int line, @@ -1578,8 +1603,12 @@ assertion_make_dir(const char *file, int line, const char *dirname, int mode) if (0 == _mkdir(dirname)) return (1); #else - if (0 == mkdir(dirname, mode)) - return (1); + if (0 == mkdir(dirname, mode)) { + if (0 == chmod(dirname, mode)) { + assertion_file_mode(file, line, dirname, mode); + return (1); + } + } #endif failure_start(file, line, "Could not create directory %s", dirname); failure_finish(NULL); @@ -1628,6 +1657,11 @@ assertion_make_file(const char *file, int line, failure_finish(NULL); return (0); } + if (0 != chmod(path, mode)) { + failure_start(file, line, "Could not chmod %s", path); + failure_finish(NULL); + return (0); + } if (contents != NULL) { ssize_t wsize; @@ -1644,6 +1678,7 @@ assertion_make_file(const char *file, int line, } } close(fd); + assertion_file_mode(file, line, path, mode); return (1); #endif } diff --git a/contrib/libarchive/cat/test/test.h b/contrib/libarchive/cat/test/test.h index c5d2363..1d21964 100644 --- a/contrib/libarchive/cat/test/test.h +++ b/contrib/libarchive/cat/test/test.h @@ -241,6 +241,7 @@ int assertion_file_birthtime_recent(const char *, int, const char *); int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **); int assertion_file_contents(const char *, int, const void *, int, const char *); int assertion_file_exists(const char *, int, const char *); +int assertion_file_mode(const char *, int, const char *, int); int assertion_file_mtime(const char *, int, const char *, long, long); int assertion_file_mtime_recent(const char *, int, const char *); int assertion_file_nlinks(const char *, int, const char *, int); |