MFhead @ r304091

This commit is contained in:
Enji Cooper 2016-08-14 19:54:40 +00:00
commit 6e4f4927ef
46 changed files with 723 additions and 126 deletions

View File

@ -83,7 +83,7 @@ DEFINE_TEST(test_version)
if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
++q;
/* Skip arbitrary third-party version numbers. */
while (s > 0 && (*q == ' ' || *q == '/' || *q == '.' || isalnum(*q))) {
while (s > 0 && (*q == ' ' || *q == '-' || *q == '/' || *q == '.' || isalnum(*q))) {
++q;
--s;
}

View File

@ -63,6 +63,7 @@ static const struct option {
} cpio_longopts[] = {
{ "b64encode", 0, OPTION_B64ENCODE },
{ "create", 0, 'o' },
{ "dereference", 0, 'L' },
{ "dot", 0, 'V' },
{ "extract", 0, 'i' },
{ "file", 1, 'F' },

View File

@ -75,7 +75,7 @@ verify(const char *p, size_t s)
if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
++q;
/* Skip arbitrary third-party version numbers. */
while (s > 0 && (*q == ' ' || *q == '/' || *q == '.' || isalnum(*q))) {
while (s > 0 && (*q == ' ' || *q == '-' || *q == '/' || *q == '.' || isalnum(*q))) {
++q;
--s;
}

View File

@ -655,7 +655,7 @@ add_pattern_from_file(struct archive_match *a, struct match_list *mlist,
}
}
/* If something error happend, report it immediately. */
/* If an error occurred, report it immediately. */
if (r < ARCHIVE_OK) {
archive_copy_error(&(a->archive), ar);
archive_read_free(ar);

View File

@ -19,7 +19,7 @@ If you need the compatibility with original PPMd var.H, you can use external Ran
#define PPMD7_MAX_ORDER 64
#define PPMD7_MIN_MEM_SIZE (1 << 11)
#define PPMD7_MAX_MEM_SIZE (0xFFFFFFFF - 12 * 3)
#define PPMD7_MAX_MEM_SIZE (0xFFFFFFFFu - 12 * 3)
struct CPpmd7_Context_;

View File

@ -125,7 +125,7 @@ void
__archive_read_reset_passphrase(struct archive_read *a)
{
a->passphrases.candiate = -1;
a->passphrases.candidate = -1;
}
/*
@ -137,31 +137,31 @@ __archive_read_next_passphrase(struct archive_read *a)
struct archive_read_passphrase *p;
const char *passphrase;
if (a->passphrases.candiate < 0) {
if (a->passphrases.candidate < 0) {
/* Count out how many passphrases we have. */
int cnt = 0;
for (p = a->passphrases.first; p != NULL; p = p->next)
cnt++;
a->passphrases.candiate = cnt;
a->passphrases.candidate = cnt;
p = a->passphrases.first;
} else if (a->passphrases.candiate > 1) {
} else if (a->passphrases.candidate > 1) {
/* Rotate a passphrase list. */
a->passphrases.candiate--;
a->passphrases.candidate--;
p = remove_passphrases_from_head(a);
add_passphrase_to_tail(a, p);
/* Pick a new passphrase candiate up. */
/* Pick a new passphrase candidate up. */
p = a->passphrases.first;
} else if (a->passphrases.candiate == 1) {
/* This case is that all cadiates failed to decryption. */
a->passphrases.candiate = 0;
} else if (a->passphrases.candidate == 1) {
/* This case is that all candidates failed to decrypt. */
a->passphrases.candidate = 0;
if (a->passphrases.first->next != NULL) {
/* Rotate a passphrase list. */
p = remove_passphrases_from_head(a);
add_passphrase_to_tail(a, p);
}
p = NULL;
} else /* There is no passphrase candaite. */
} else /* There is no passphrase candidate. */
p = NULL;
if (p != NULL)
@ -177,7 +177,7 @@ __archive_read_next_passphrase(struct archive_read *a)
if (p == NULL)
return (NULL);
insert_passphrase_to_head(a, p);
a->passphrases.candiate = 1;
a->passphrases.candidate = 1;
}
} else
passphrase = NULL;

View File

@ -641,13 +641,16 @@ translate_acl(struct archive_read_disk *a,
* Libarchive stores "flag" (NFSv4 inheritance bits)
* in the ae_perm bitmap.
*/
acl_get_flagset_np(acl_entry, &acl_flagset);
for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
if (acl_get_flag_np(acl_flagset,
acl_inherit_map[i].platform_inherit))
ae_perm |= acl_inherit_map[i].archive_inherit;
}
// XXX acl_get_flagset_np on FreeBSD returns EINVAL for
// non-NFSv4 ACLs
r = acl_get_flagset_np(acl_entry, &acl_flagset);
if (r == 0) {
for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
if (acl_get_flag_np(acl_flagset,
acl_inherit_map[i].platform_inherit))
ae_perm |= acl_inherit_map[i].archive_inherit;
}
}
#endif
acl_get_permset(acl_entry, &acl_permset);

View File

@ -938,7 +938,7 @@ next_entry(struct archive_read_disk *a, struct tree *t,
r = archive_match_path_excluded(a->matching, entry);
if (r < 0) {
archive_set_error(&(a->archive), errno,
"Faild : %s", archive_error_string(a->matching));
"Failed : %s", archive_error_string(a->matching));
return (r);
}
if (r) {
@ -1041,7 +1041,7 @@ next_entry(struct archive_read_disk *a, struct tree *t,
r = archive_match_time_excluded(a->matching, entry);
if (r < 0) {
archive_set_error(&(a->archive), errno,
"Faild : %s", archive_error_string(a->matching));
"Failed : %s", archive_error_string(a->matching));
return (r);
}
if (r) {
@ -1067,7 +1067,7 @@ next_entry(struct archive_read_disk *a, struct tree *t,
r = archive_match_owner_excluded(a->matching, entry);
if (r < 0) {
archive_set_error(&(a->archive), errno,
"Faild : %s", archive_error_string(a->matching));
"Failed : %s", archive_error_string(a->matching));
return (r);
}
if (r) {

View File

@ -221,7 +221,7 @@ struct archive_read {
struct {
struct archive_read_passphrase *first;
struct archive_read_passphrase **last;
int candiate;
int candidate;
archive_passphrase_callback *callback;
void *client_data;
} passphrases;

View File

@ -595,7 +595,7 @@ lz4_filter_read_data_block(struct archive_read_filter *self, const void **p)
#endif
}
/* Check if an error happend in decompression process. */
/* Check if an error occurred in the decompression process. */
if (uncompressed_size < 0) {
archive_set_error(&(self->archive->archive),
ARCHIVE_ERRNO_MISC, "lz4 decompression failed");

View File

@ -1715,8 +1715,11 @@ lha_crc16(uint16_t crc, const void *pp, size_t len)
#undef bswap16
#if defined(_MSC_VER) && _MSC_VER >= 1400 /* Visual Studio */
# define bswap16(x) _byteswap_ushort(x)
#elif (defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 8) \
|| defined(__clang__)
#elif defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || __GNUC__ > 4)
/* GCC 4.8 and later has __builtin_bswap16() */
# define bswap16(x) __builtin_bswap16(x)
#elif defined(__clang__)
/* All clang versions have __builtin_bswap16() */
# define bswap16(x) __builtin_bswap16(x)
#else
# define bswap16(x) ((((x) >> 8) & 0xff) | ((x) << 8))

View File

@ -318,7 +318,7 @@ _warc_rdhdr(struct archive_read *a, struct archive_entry *entry)
}
memcpy(w->pool.str, fnam.str, fnam.len);
w->pool.str[fnam.len] = '\0';
/* let noone else know about the pool, it's a secret, shhh */
/* let no one else know about the pool, it's a secret, shhh */
fnam.str = w->pool.str;
/* snarf mtime or deduce from rtime

View File

@ -580,7 +580,7 @@ void
__archive_ensure_cloexec_flag(int fd)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
(void)fd; /* UNSED */
(void)fd; /* UNUSED */
#else
int flags;

View File

@ -145,7 +145,7 @@ set_acl(struct archive *a, int fd, const char *name,
gid_t ae_gid;
const char *ae_name;
int entries;
int i;
int i, r;
ret = ARCHIVE_OK;
entries = archive_acl_reset(abstract_acl, ae_requested_type);
@ -223,12 +223,16 @@ set_acl(struct archive *a, int fd, const char *name,
}
#ifdef ACL_TYPE_NFS4
acl_get_flagset_np(acl_entry, &acl_flagset);
acl_clear_flags_np(acl_flagset);
for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
if (ae_permset & acl_inherit_map[i].archive_inherit)
acl_add_flag_np(acl_flagset,
acl_inherit_map[i].platform_inherit);
// XXX acl_get_flagset_np on FreeBSD returns EINVAL for
// non-NFSv4 ACLs
r = acl_get_flagset_np(acl_entry, &acl_flagset);
if (r == 0) {
acl_clear_flags_np(acl_flagset);
for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
if (ae_permset & acl_inherit_map[i].archive_inherit)
acl_add_flag_np(acl_flagset,
acl_inherit_map[i].platform_inherit);
}
}
#endif
}

View File

@ -1796,7 +1796,7 @@ edit_deep_directories(struct archive_write_disk *a)
char *tail = a->name;
/* If path is short, avoid the open() below. */
if (strlen(tail) <= PATH_MAX)
if (strlen(tail) < PATH_MAX)
return;
/* Try to record our starting dir. */
@ -1806,7 +1806,7 @@ edit_deep_directories(struct archive_write_disk *a)
return;
/* As long as the path is too long... */
while (strlen(tail) > PATH_MAX) {
while (strlen(tail) >= PATH_MAX) {
/* Locate a dir prefix shorter than PATH_MAX. */
tail += PATH_MAX - 8;
while (tail > a->name && *tail != '/')

View File

@ -436,7 +436,7 @@ struct iso_option {
* Type : string
* Default: Auto detect
* : We check a size of boot image;
* : If ths size is just 1.22M/1.44M/2.88M,
* : If the size is just 1.22M/1.44M/2.88M,
* : we assume boot_type is 'fd';
* : otherwise boot_type is 'no-emulation'.
* COMPAT :

View File

@ -307,7 +307,7 @@ archive_write_ustar_header(struct archive_write *a, struct archive_entry *entry)
* case getting WCS failed. On POSIX, this is a
* normal operation.
*/
if (p != NULL && p[strlen(p) - 1] != '/') {
if (p != NULL && p[0] != '\0' && p[strlen(p) - 1] != '/') {
struct archive_string as;
archive_string_init(&as);

View File

@ -1440,6 +1440,31 @@ assertion_file_size(const char *file, int line, const char *pathname, long size)
return (0);
}
/* 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);
}
/* Assert that 'pathname' is a dir. If mode >= 0, verify that too. */
int
assertion_is_dir(const char *file, int line, const char *pathname, int mode)

View File

@ -182,6 +182,8 @@
assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks)
#define assertFileSize(pathname, size) \
assertion_file_size(__FILE__, __LINE__, pathname, size)
#define assertFileMode(pathname, mode) \
assertion_file_mode(__FILE__, __LINE__, pathname, mode)
#define assertTextFileContents(text, pathname) \
assertion_text_file_contents(__FILE__, __LINE__, text, pathname)
#define assertFileContainsLinesAnyOrder(pathname, lines) \
@ -246,6 +248,7 @@ int assertion_file_mtime_recent(const char *, int, const char *);
int assertion_file_nlinks(const char *, int, const char *, int);
int assertion_file_not_exists(const char *, int, const char *);
int assertion_file_size(const char *, int, const char *, long);
int assertion_file_mode(const char *, int, const char *, int);
int assertion_is_dir(const char *, int, const char *, int);
int assertion_is_hardlink(const char *, int, const char *, const char *);
int assertion_is_not_hardlink(const char *, int, const char *, const char *);

View File

@ -800,8 +800,8 @@ DEFINE_TEST(test_archive_string_conversion)
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assert((fp = fopen(testdata, "w")) != NULL);
while ((size = archive_read_data(a, buff, 512)) > 0)
fwrite(buff, 1, size, fp);
fclose(fp);
assertEqualInt(size, fwrite(buff, 1, size, fp));
assertEqualInt(0, fclose(fp));
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
test_archive_string_normalization_nfc(testdata);

View File

@ -110,13 +110,17 @@ test_fuzz(const struct files *filesets)
for (i = 0; filesets[n].names[i] != NULL; ++i)
{
tmp = slurpfile(&size, filesets[n].names[i]);
rawimage = (char *)realloc(rawimage, oldsize + size);
char *newraw = (char *)realloc(rawimage, oldsize + size);
if (!assert(newraw != NULL))
{
free(rawimage);
continue;
}
rawimage = newraw;
memcpy(rawimage + oldsize, tmp, size);
oldsize += size;
size = oldsize;
free(tmp);
if (!assert(rawimage != NULL))
continue;
}
}
if (size == 0)

View File

@ -3603,7 +3603,7 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files)
assertEqualIntA(a, 0, archive_read_data(a, buff, sizeof(buff)));
/*
* Eigth header.
* Eighth header.
*/
assertA(0 == archive_read_next_header(a, &ae));
assertEqualString("testdir/testsymlink6", archive_entry_pathname(ae));

View File

@ -0,0 +1,143 @@
/*-
* Copyright (c) 2016 Tim Kientzle
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
__FBSDID("$FreeBSD");
#include <locale.h>
/*
* Github Issue 748 reported problems with end-of-entry handling
* with highly-compressible data. This resulted in the end of the
* data being truncated (extracted as zero bytes).
*/
/*
* Extract the specific test archive that was used to diagnose
* Issue 748:
*/
DEFINE_TEST(test_read_format_zip_high_compression)
{
const char *refname = "test_read_format_zip_high_compression.zip";
char *p;
size_t archive_size;
struct archive *a;
struct archive_entry *entry;
const void *pv;
size_t s;
int64_t o;
extract_reference_file(refname);
p = slurpfile(&archive_size, refname);
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a));
assertEqualIntA(a, ARCHIVE_OK, read_open_memory_seek(a, p, archive_size, 16 * 1024));
assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &entry));
assertEqualInt(ARCHIVE_OK, archive_read_data_block(a, &pv, &s, &o));
assertEqualInt(262144, s);
assertEqualInt(0, o);
assertEqualInt(ARCHIVE_OK, archive_read_data_block(a, &pv, &s, &o));
assertEqualInt(160, s);
assertEqualInt(262144, o);
assertEqualInt(ARCHIVE_EOF, archive_read_data_block(a, &pv, &s, &o));
assertEqualInt(ARCHIVE_OK, archive_free(a));
free(p);
}
/*
* Synthesize a lot of varying inputs that are highly compressible.
*/
DEFINE_TEST(test_read_format_zip_high_compression2)
{
const size_t body_size = 1024 * 1024;
const size_t buff_size = 2 * 1024 * 1024;
char *body, *body_read, *buff;
int n;
assert((body = malloc(body_size)) != NULL);
assert((body_read = malloc(body_size)) != NULL);
assert((buff = malloc(buff_size)) != NULL);
/* Highly-compressible data: all bytes 255, except for a
* single 1 byte.
* The body is always 256k + 6 bytes long (the internal deflation
* buffer is exactly 256k).
*/
for(n = 1024; n < (int)body_size; n += 1024) {
struct archive *a;
struct archive_entry *entry;
size_t used = 0;
const void *pv;
size_t s;
int64_t o;
memset(body, 255, body_size);
body[n] = 1;
/* Write an archive with a single entry of n bytes. */
assert((a = archive_write_new()) != NULL);
assertEqualInt(ARCHIVE_OK, archive_write_set_format_zip(a));
assertEqualInt(ARCHIVE_OK, archive_write_open_memory(a, buff, buff_size, &used));
entry = archive_entry_new2(a);
archive_entry_set_pathname(entry, "test");
archive_entry_set_filetype(entry, AE_IFREG);
archive_entry_set_size(entry, 262150);
assertEqualInt(ARCHIVE_OK, archive_write_header(a, entry));
archive_entry_free(entry);
assertEqualInt(262150, archive_write_data(a, body, 262150));
assertEqualInt(ARCHIVE_OK, archive_write_free(a));
/* Read back the entry and verify the contents. */
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, buff, used, 17));
assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &entry));
assertEqualInt(ARCHIVE_OK, archive_read_data_block(a, &pv, &s, &o));
assertEqualInt(262144, s);
assertEqualInt(0, o);
assertEqualInt(ARCHIVE_OK, archive_read_data_block(a, &pv, &s, &o));
assertEqualInt(6, s);
assertEqualInt(262144, o);
assertEqualInt(ARCHIVE_EOF, archive_read_data_block(a, &pv, &s, &o));
assertEqualInt(ARCHIVE_OK, archive_free(a));
}
free(body);
free(body_read);
free(buff);
}

View File

@ -0,0 +1,18 @@
begin 644 test_read_format_zip_high_compression.zip
M4$L#!!0`"``(`*=Y]4@``````````*``!``(`"``8VAA<BYB:6Y55`T`!\L>
MD5>>))%7GB215W5X"P`!!/8!```$%````.W=06K#,!`%T&E)P8LL?*2XC@N%
M)#5QO>AM<K0<+2=0:!OBP>@9WDJ6!%\6$K/Q6T3LAX]N/GQ'Z9G&KA^*K1'S
M.`[GOIM*[TP_Q_>O0[G_:3X.Y\^^V/X2<<GT&IM=$]OK?[71_LJ],3;1+*(T
M_U)99\T+````````````````````````````````````````L`:E?]*S#FVT
MJY:='SPB>_]DR\X?`("_R:X_U"Y[_:F;;Q``ZN+L!P"H3W;]$_5G`&!9V?</
M````X/FRZP_9LO,'@`S9YR^0P_Z'NF7?/P``````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
MJ%L3VVM-LO,&8/UN4$L'"!<='%^U`0``H``$`%!+`0(4`Q0`"``(`*=Y]4@7
M'1Q?M0$``*``!``(`"````````````"D@0````!C:&%R+F)I;E54#0`'RQZ1
M5YXDD5>>))%7=7@+``$$]@$```04````4$L%!@`````!``$`5@````L"````
!````
`
end

View File

@ -0,0 +1,95 @@
/*-
* Copyright (c) 2003-2007,2016 Tim Kientzle
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
__FBSDID("$FreeBSD$");
#define UMASK 022
/*
* Github Issue #744 describes a bug in the sandboxing code that
* causes very long pathnames to not get checked for symlinks.
*/
DEFINE_TEST(test_write_disk_secure744)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
skipping("archive_write_disk security checks not supported on Windows");
#else
struct archive *a;
struct archive_entry *ae;
size_t buff_size = 8192;
char *buff = malloc(buff_size);
char *p = buff;
int n = 0;
int t;
assert(buff != NULL);
/* Start with a known umask. */
assertUmask(UMASK);
/* Create an archive_write_disk object. */
assert((a = archive_write_disk_new()) != NULL);
archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS);
while (p + 500 < buff + buff_size) {
memset(p, 'x', 100);
p += 100;
p[0] = '\0';
buff[0] = ((n / 1000) % 10) + '0';
buff[1] = ((n / 100) % 10)+ '0';
buff[2] = ((n / 10) % 10)+ '0';
buff[3] = ((n / 1) % 10)+ '0';
buff[4] = '_';
++n;
/* Create a symlink pointing to the testworkdir */
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, buff);
archive_entry_set_mode(ae, S_IFREG | 0777);
archive_entry_copy_symlink(ae, testworkdir);
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
archive_entry_free(ae);
*p++ = '/';
sprintf(p, "target%d", n);
/* Try to create a file through the symlink, should fail. */
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, buff);
archive_entry_set_mode(ae, S_IFDIR | 0777);
t = archive_write_header(a, ae);
archive_entry_free(ae);
failure("Attempt to create target%d via %d-character symlink should have failed", n, (int)strlen(buff));
if(!assertEqualInt(ARCHIVE_FAILED, t)) {
break;
}
}
archive_free(a);
free(buff);
#endif
}

View File

@ -0,0 +1,76 @@
/*-
* Copyright (c) 2003-2007,2016 Tim Kientzle
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
__FBSDID("$FreeBSD$");
#define UMASK 022
/*
* Github Issue #745 describes a bug in the sandboxing code that
* allows one to use a symlink to edit the permissions on a file or
* directory outside of the sandbox.
*/
DEFINE_TEST(test_write_disk_secure745)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
skipping("archive_write_disk security checks not supported on Windows");
#else
struct archive *a;
struct archive_entry *ae;
/* Start with a known umask. */
assertUmask(UMASK);
/* Create an archive_write_disk object. */
assert((a = archive_write_disk_new()) != NULL);
archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS);
/* The target dir: The one we're going to try to change permission on */
assertMakeDir("target", 0700);
/* The sandbox dir we're going to run inside of. */
assertMakeDir("sandbox", 0700);
assertChdir("sandbox");
/* Create a symlink pointing to the target directory */
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, "sym");
archive_entry_set_mode(ae, S_IFREG | 0777);
archive_entry_copy_symlink(ae, "../target");
assert(0 == archive_write_header(a, ae));
archive_entry_free(ae);
/* Try to alter the target dir through the symlink; this should fail. */
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, "sym");
archive_entry_set_mode(ae, S_IFDIR | 0777);
assert(0 == archive_write_header(a, ae));
archive_entry_free(ae);
/* Permission of target dir should not have changed. */
assertFileMode("../target", 0700);
#endif
}

View File

@ -0,0 +1,125 @@
/*-
* Copyright (c) 2003-2007,2016 Tim Kientzle
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
__FBSDID("$FreeBSD$");
#define UMASK 022
/*
* Github Issue #746 describes a problem in which hardlink targets are
* not adequately checked and can be used to modify entries outside of
* the sandbox.
*/
/*
* Verify that ARCHIVE_EXTRACT_SECURE_NODOTDOT disallows '..' in hardlink
* targets.
*/
DEFINE_TEST(test_write_disk_secure746a)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
skipping("archive_write_disk security checks not supported on Windows");
#else
struct archive *a;
struct archive_entry *ae;
/* Start with a known umask. */
assertUmask(UMASK);
/* The target directory we're going to try to affect. */
assertMakeDir("target", 0700);
assertMakeFile("target/foo", 0700, "unmodified");
/* The sandbox dir we're going to work within. */
assertMakeDir("sandbox", 0700);
assertChdir("sandbox");
/* Create an archive_write_disk object. */
assert((a = archive_write_disk_new()) != NULL);
archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_NODOTDOT);
/* Attempt to hardlink to the target directory. */
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, "bar");
archive_entry_set_mode(ae, S_IFREG | 0777);
archive_entry_set_size(ae, 8);
archive_entry_copy_hardlink(ae, "../target/foo");
assertEqualInt(ARCHIVE_FAILED, archive_write_header(a, ae));
assertEqualInt(ARCHIVE_FAILED, archive_write_data(a, "modified", 8));
archive_entry_free(ae);
/* Verify that target file contents are unchanged. */
assertTextFileContents("unmodified", "../target/foo");
#endif
}
/*
* Verify that ARCHIVE_EXTRACT_SECURE_NOSYMLINK disallows symlinks in hardlink
* targets.
*/
DEFINE_TEST(test_write_disk_secure746b)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
skipping("archive_write_disk security checks not supported on Windows");
#else
struct archive *a;
struct archive_entry *ae;
/* Start with a known umask. */
assertUmask(UMASK);
/* The target directory we're going to try to affect. */
assertMakeDir("target", 0700);
assertMakeFile("target/foo", 0700, "unmodified");
/* The sandbox dir we're going to work within. */
assertMakeDir("sandbox", 0700);
assertChdir("sandbox");
/* Create an archive_write_disk object. */
assert((a = archive_write_disk_new()) != NULL);
archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS);
/* Create a symlink to the target directory. */
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, "symlink");
archive_entry_copy_symlink(ae, "../target");
assertEqualInt(ARCHIVE_FAILED, archive_write_header(a, ae));
archive_entry_free(ae);
/* Attempt to hardlink to the target directory via the symlink. */
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, "bar");
archive_entry_set_mode(ae, S_IFREG | 0777);
archive_entry_set_size(ae, 8);
archive_entry_copy_hardlink(ae, "symlink/foo");
assertEqualInt(ARCHIVE_FAILED, archive_write_header(a, ae));
assertEqualInt(ARCHIVE_FAILED, archive_write_data(a, "modified", 8));
archive_entry_free(ae);
/* Verify that target file contents are unchanged. */
assertTextFileContents("unmodified", "../target/foo");
#endif
}

View File

@ -68,6 +68,7 @@ static const struct bsdtar_option {
{ "auto-compress", 0, 'a' },
{ "b64encode", 0, OPTION_B64ENCODE },
{ "block-size", 1, 'b' },
{ "blocking-factor", 1, 'b' },
{ "bunzip2", 0, 'j' },
{ "bzip", 0, 'j' },
{ "bzip2", 0, 'j' },

View File

@ -88,7 +88,7 @@ DEFINE_TEST(test_version)
if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
++q;
/* Skip arbitrary third-party version numbers. */
while (s > 0 && (*q == ' ' || *q == '/' || *q == '.' || isalnum(*q))) {
while (s > 0 && (*q == ' ' || *q == '-' || *q == '/' || *q == '.' || isalnum(*q))) {
++q;
--s;
}

View File

@ -32,4 +32,5 @@ KEYPRINT=9b5feee6d69f170e3dd0a2c8e469ddbd64f13f978f2f3aede40c98633216c330
# List of INDEX files to build and the DESCRIBE file to use for each
#INDEX INDEX-9 DESCRIBE.9
#INDEX INDEX-10 DESCRIBE.10
INDEX INDEX-11 DESCRIBE.11
#INDEX INDEX-11 DESCRIBE.11
INDEX INDEX-12 DESCRIBE.12

View File

@ -175,6 +175,7 @@ TESTS_SRCS= \
test_read_format_zip_encryption_header.c \
test_read_format_zip_encryption_partially.c \
test_read_format_zip_filename.c \
test_read_format_zip_high_compression.c \
test_read_format_zip_mac_metadata.c \
test_read_format_zip_malformed.c \
test_read_format_zip_msdos.c \
@ -209,6 +210,9 @@ TESTS_SRCS= \
test_write_disk_no_hfs_compression.c \
test_write_disk_perms.c \
test_write_disk_secure.c \
test_write_disk_secure744.c \
test_write_disk_secure745.c \
test_write_disk_secure746.c \
test_write_disk_sparse.c \
test_write_disk_symlink.c \
test_write_disk_times.c \
@ -504,6 +508,7 @@ ${PACKAGE}FILES+= test_read_format_zip_filename_koi8r.zip.uu
${PACKAGE}FILES+= test_read_format_zip_filename_utf8_jp.zip.uu
${PACKAGE}FILES+= test_read_format_zip_filename_utf8_ru.zip.uu
${PACKAGE}FILES+= test_read_format_zip_filename_utf8_ru2.zip.uu
${PACKAGE}FILES+= test_read_format_zip_high_compression.zip.uu
${PACKAGE}FILES+= test_read_format_zip_length_at_end.zip.uu
${PACKAGE}FILES+= test_read_format_zip_mac_metadata.zip.uu
${PACKAGE}FILES+= test_read_format_zip_malformed1.zip.uu

View File

@ -3718,11 +3718,14 @@ compile_rule(char *av[], uint32_t *rbuf, int *rbufsize, struct tidx *tstate)
}
if (strcmp(*av, "any") == 0)
action->arg1 = 0;
else if (match_token(rule_options, *av) != -1) {
else if ((i = match_token(rule_options, *av)) != -1) {
action->arg1 = pack_object(tstate,
default_state_name, IPFW_TLV_STATE_NAME);
warn("Ambiguous state name '%s', '%s' used instead.\n",
*av, default_state_name);
if (i != TOK_COMMENT)
warn("Ambiguous state name '%s', '%s'"
" used instead.\n", *av,
default_state_name);
break;
} else if (state_check_name(*av) == 0)
action->arg1 = pack_object(tstate, *av,
IPFW_TLV_STATE_NAME);
@ -4117,8 +4120,17 @@ compile_rule(char *av[], uint32_t *rbuf, int *rbufsize, struct tidx *tstate)
cmd = next_cmd(cmd, &cblen);
}
if (have_state) /* must be a check-state, we are done */
if (have_state) { /* must be a check-state, we are done */
if (*av != NULL &&
match_token(rule_options, *av) == TOK_COMMENT) {
/* check-state has a comment */
av++;
fill_comment(cmd, av, cblen);
cmd = next_cmd(cmd, &cblen);
av[0] = NULL;
}
goto done;
}
#define OR_START(target) \
if (av[0] && (*av[0] == '(' || *av[0] == '{')) { \
@ -4563,8 +4575,8 @@ compile_rule(char *av[], uint32_t *rbuf, int *rbufsize, struct tidx *tstate)
errx(EX_USAGE, "only one of keep-state "
"and limit is allowed");
if (*av == NULL ||
match_token(rule_options, *av) != -1) {
if (*av != NULL)
(i = match_token(rule_options, *av)) != -1) {
if (*av != NULL && i != TOK_COMMENT)
warn("Ambiguous state name '%s',"
" '%s' used instead.\n", *av,
default_state_name);
@ -4615,8 +4627,8 @@ compile_rule(char *av[], uint32_t *rbuf, int *rbufsize, struct tidx *tstate)
av++;
if (*av == NULL ||
match_token(rule_options, *av) != -1) {
if (*av != NULL)
(i = match_token(rule_options, *av)) != -1) {
if (*av != NULL && i != TOK_COMMENT)
warn("Ambiguous state name '%s',"
" '%s' used instead.\n", *av,
default_state_name);

View File

@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <inttypes.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
@ -687,7 +688,6 @@ nat64lsn_get_stats(const char *name, uint8_t set,
return (-1);
}
#define _P_STAT(_s, _f) printf("%8s:\t%lu\n", #_f, _s._f)
static void
nat64lsn_stats(const char *name, uint8_t set)
{
@ -696,34 +696,61 @@ nat64lsn_stats(const char *name, uint8_t set)
if (nat64lsn_get_stats(name, set, &stats) != 0)
err(EX_OSERR, "Error retrieving stats");
_P_STAT(stats, opcnt64);
_P_STAT(stats, opcnt46);
_P_STAT(stats, ofrags);
_P_STAT(stats, ifrags);
_P_STAT(stats, oerrors);
_P_STAT(stats, noroute4);
_P_STAT(stats, noroute6);
_P_STAT(stats, noproto);
_P_STAT(stats, nomem);
_P_STAT(stats, dropped);
if (co.use_set != 0 || set != 0)
printf("set %u ", set);
printf("nat64lsn %s\n", name);
printf("\t%ju packets translated from IPv6 to IPv4\n",
(uintmax_t)stats.opcnt64);
printf("\t%ju packets translated from IPv4 to IPv6\n",
(uintmax_t)stats.opcnt46);
printf("\t%ju IPv6 fragments created\n",
(uintmax_t)stats.ofrags);
printf("\t%ju IPv4 fragments received\n",
(uintmax_t)stats.ifrags);
printf("\t%ju output packets dropped due to no bufs, etc.\n",
(uintmax_t)stats.oerrors);
printf("\t%ju output packets discarded due to no IPv4 route\n",
(uintmax_t)stats.noroute4);
printf("\t%ju output packets discarded due to no IPv6 route\n",
(uintmax_t)stats.noroute6);
printf("\t%ju packets discarded due to unsupported protocol\n",
(uintmax_t)stats.noproto);
printf("\t%ju packets discarded due to memory allocation problems\n",
(uintmax_t)stats.nomem);
printf("\t%ju packets discarded due to some errors\n",
(uintmax_t)stats.dropped);
printf("\t%ju packets not matched with IPv4 prefix\n",
(uintmax_t)stats.nomatch4);
_P_STAT(stats, hostcount);
_P_STAT(stats, tcpchunks);
_P_STAT(stats, udpchunks);
_P_STAT(stats, icmpchunks);
_P_STAT(stats, jcalls);
_P_STAT(stats, jrequests);
_P_STAT(stats, jhostsreq);
_P_STAT(stats, jportreq);
_P_STAT(stats, jhostfails);
_P_STAT(stats, jportfails);
_P_STAT(stats, jreinjected);
_P_STAT(stats, jmaxlen);
_P_STAT(stats, jnomem);
_P_STAT(stats, screated);
_P_STAT(stats, sdeleted);
_P_STAT(stats, spgcreated);
_P_STAT(stats, spgdeleted);
printf("\t%ju mbufs queued for post processing\n",
(uintmax_t)stats.jreinjected);
printf("\t%ju times the job queue was processed\n",
(uintmax_t)stats.jcalls);
printf("\t%ju job requests queued\n",
(uintmax_t)stats.jrequests);
printf("\t%ju job requests queue limit reached\n",
(uintmax_t)stats.jmaxlen);
printf("\t%ju job requests failed due to memory allocation problems\n",
(uintmax_t)stats.jnomem);
printf("\t%ju hosts allocated\n", (uintmax_t)stats.hostcount);
printf("\t%ju hosts requested\n", (uintmax_t)stats.jhostsreq);
printf("\t%ju host requests failed\n", (uintmax_t)stats.jhostfails);
printf("\t%ju portgroups requested\n", (uintmax_t)stats.jportreq);
printf("\t%ju portgroups allocated\n", (uintmax_t)stats.spgcreated);
printf("\t%ju portgroups deleted\n", (uintmax_t)stats.spgdeleted);
printf("\t%ju portgroup requests failed\n",
(uintmax_t)stats.jportfails);
printf("\t%ju portgroups allocated for TCP\n",
(uintmax_t)stats.tcpchunks);
printf("\t%ju portgroups allocated for UDP\n",
(uintmax_t)stats.udpchunks);
printf("\t%ju portgroups allocated for ICMP\n",
(uintmax_t)stats.icmpchunks);
printf("\t%ju states created\n", (uintmax_t)stats.screated);
printf("\t%ju states deleted\n", (uintmax_t)stats.sdeleted);
}
static int

View File

@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <inttypes.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
@ -386,7 +387,6 @@ nat64stl_get_stats(const char *name, uint8_t set,
return (-1);
}
#define _P_STAT(_s, _f) printf("%8s:\t%lu\n", #_f, _s._f)
static void
nat64stl_stats(const char *name, uint8_t set)
{
@ -395,16 +395,30 @@ nat64stl_stats(const char *name, uint8_t set)
if (nat64stl_get_stats(name, set, &stats) != 0)
err(EX_OSERR, "Error retrieving stats");
_P_STAT(stats, opcnt64);
_P_STAT(stats, opcnt46);
_P_STAT(stats, ofrags);
_P_STAT(stats, ifrags);
_P_STAT(stats, oerrors);
_P_STAT(stats, noroute4);
_P_STAT(stats, noroute6);
_P_STAT(stats, noproto);
_P_STAT(stats, nomem);
_P_STAT(stats, dropped);
if (co.use_set != 0 || set != 0)
printf("set %u ", set);
printf("nat64stl %s\n", name);
printf("\t%ju packets translated from IPv6 to IPv4\n",
(uintmax_t)stats.opcnt64);
printf("\t%ju packets translated from IPv4 to IPv6\n",
(uintmax_t)stats.opcnt46);
printf("\t%ju IPv6 fragments created\n",
(uintmax_t)stats.ofrags);
printf("\t%ju IPv4 fragments received\n",
(uintmax_t)stats.ifrags);
printf("\t%ju output packets dropped due to no bufs, etc.\n",
(uintmax_t)stats.oerrors);
printf("\t%ju output packets discarded due to no IPv4 route\n",
(uintmax_t)stats.noroute4);
printf("\t%ju output packets discarded due to no IPv6 route\n",
(uintmax_t)stats.noroute6);
printf("\t%ju packets discarded due to unsupported protocol\n",
(uintmax_t)stats.noproto);
printf("\t%ju packets discarded due to memory allocation problems\n",
(uintmax_t)stats.nomem);
printf("\t%ju packets discarded due to some errors\n",
(uintmax_t)stats.dropped);
}
/*

View File

@ -309,11 +309,14 @@ nptv6_stats(const char *name, uint8_t set)
if (nptv6_get_stats(name, set, &stats) != 0)
err(EX_OSERR, "Error retrieving stats");
printf("Number of packets translated (internal to external): %ju\n",
if (co.use_set != 0 || set != 0)
printf("set %u ", set);
printf("nptv6 %s\n", name);
printf("\t%ju packets translated (internal to external)\n",
(uintmax_t)stats.in2ex);
printf("Number of packets translated (external to internal): %ju\n",
printf("\t%ju packets translated (external to internal)\n",
(uintmax_t)stats.ex2in);
printf("Number of packets dropped due to some error: %ju\n",
printf("\t%ju packets dropped due to some error\n",
(uintmax_t)stats.dropped);
}

View File

@ -358,7 +358,7 @@ static device_method_t ehci_methods[] = {
static driver_t ehci_driver = {
.name = "ehci",
.methods = ehci_methods,
.size = sizeof(ehci_softc_t),
.size = sizeof(struct aw_ehci_softc),
};
static devclass_t ehci_devclass;

View File

@ -69,10 +69,10 @@ DB_SHOW_ALL_COMMAND(procs, db_procs_cmd)
*
* 1 2 3 4 5 6 7
* 1234567890123456789012345678901234567890123456789012345678901234567890
* pid ppid pgrp uid state wmesg wchan cmd
* <pid> <ppi> <pgi> <uid> <stat> < wmesg > < wchan > <name>
* pid ppid pgrp uid state wmesg wchan cmd
* <pid> <ppi> <pgi> <uid> <stat> <wmesg> <wchan > <name>
* <pid> <ppi> <pgi> <uid> <stat> (threaded) <command>
* <tid > <stat> < wmesg > < wchan > <name>
* <tid > <stat> <wmesg> <wchan > <name>
*
* For machines with 64-bit pointers, we expand the wchan field 8 more
* characters.
@ -95,9 +95,9 @@ db_ps(db_expr_t addr, bool hasaddr, db_expr_t count, char *modif)
p = &proc0;
#ifdef __LP64__
db_printf(" pid ppid pgrp uid state wmesg wchan cmd\n");
db_printf(" pid ppid pgrp uid state wmesg wchan cmd\n");
#else
db_printf(" pid ppid pgrp uid state wmesg wchan cmd\n");
db_printf(" pid ppid pgrp uid state wmesg wchan cmd\n");
#endif
while (--np >= 0 && !db_pager_quit) {
if (p == NULL) {
@ -279,15 +279,15 @@ dumpthread(volatile struct proc *p, volatile struct thread *td, int all)
wmesg = "";
wchan = NULL;
}
db_printf("%c%-8.8s ", wprefix, wmesg);
db_printf("%c%-7.7s ", wprefix, wmesg);
if (wchan == NULL)
#ifdef __LP64__
db_printf("%18s ", "");
db_printf("%18s ", "");
#else
db_printf("%10s ", "");
db_printf("%10s ", "");
#endif
else
db_printf("%p ", wchan);
db_printf("%p ", wchan);
if (p->p_flag & P_SYSTEM)
db_printf("[");
if (td->td_name[0] != '\0')

View File

@ -145,7 +145,6 @@ db_stop_at_pc(bool *is_breakpoint)
if (db_sstep_print) {
db_printf("\t\t");
db_print_loc_and_inst(pc);
db_printf("\n");
}
return (false); /* continue */
}
@ -165,7 +164,6 @@ db_stop_at_pc(bool *is_breakpoint)
for (i = db_call_depth; --i > 0; )
db_printf(" ");
db_print_loc_and_inst(pc);
db_printf("\n");
}
}
if (inst_call(ins))

View File

@ -414,14 +414,14 @@ ofw_pci_alloc_resource(device_t bus, device_t child, int type, int *rid,
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
if (type == PCI_RES_BUS) {
return (pci_domain_alloc_bus(sc->sc_pci_domain, child, rid,
start, end, count, flags));
start, end, count, flags | needactivate));
}
#endif
rm = ofw_pci_get_rman(sc, type, flags);
if (rm == NULL) {
return (bus_generic_alloc_resource(bus, child, type, rid,
start, end, count, flags));
start, end, count, flags | needactivate));
}
rv = rman_reserve_resource(rm, start, end, count, flags, child);

View File

@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysent.h>
#include <machine/cpu.h>
#include <machine/frame.h>
#include <machine/md_var.h>
#include <machine/pcb.h>
#include <machine/reg.h>
@ -81,8 +82,8 @@ struct db_variable *db_eregs = db_regs + nitems(db_regs);
static __inline int
get_esp(struct trapframe *tf)
{
return ((ISPL(tf->tf_cs)) ? tf->tf_esp :
(db_expr_t)tf + (uintptr_t)DB_OFFSET(tf_esp));
return ((ISPL(tf->tf_cs) || kdb_frame->tf_eflags & PSL_VM) ?
tf->tf_esp : (intptr_t)&tf->tf_esp);
}
static int
@ -104,12 +105,32 @@ db_frame(struct db_variable *vp, db_expr_t *valuep, int op)
static int
db_frame_seg(struct db_variable *vp, db_expr_t *valuep, int op)
{
struct trapframe_vm86 *tfp;
int off;
uint16_t *reg;
if (kdb_frame == NULL)
return (0);
reg = (uint16_t *)((uintptr_t)kdb_frame + (db_expr_t)vp->valuep);
off = (intptr_t)vp->valuep;
if (kdb_frame->tf_eflags & PSL_VM) {
tfp = (void *)kdb_frame;
switch ((intptr_t)vp->valuep) {
case (intptr_t)DB_OFFSET(tf_cs):
reg = (uint16_t *)&tfp->tf_cs;
break;
case (intptr_t)DB_OFFSET(tf_ds):
reg = (uint16_t *)&tfp->tf_vm86_ds;
break;
case (intptr_t)DB_OFFSET(tf_es):
reg = (uint16_t *)&tfp->tf_vm86_es;
break;
case (intptr_t)DB_OFFSET(tf_fs):
reg = (uint16_t *)&tfp->tf_vm86_fs;
break;
}
} else
reg = (uint16_t *)((uintptr_t)kdb_frame + off);
if (op == DB_VAR_GET)
*valuep = *reg;
else
@ -134,7 +155,16 @@ db_esp(struct db_variable *vp, db_expr_t *valuep, int op)
static int
db_gs(struct db_variable *vp, db_expr_t *valuep, int op)
{
struct trapframe_vm86 *tfp;
if (kdb_frame != NULL && kdb_frame->tf_eflags & PSL_VM) {
tfp = (void *)kdb_frame;
if (op == DB_VAR_GET)
*valuep = tfp->tf_vm86_gs;
else
tfp->tf_vm86_gs = *valuep;
return (1);
}
if (op == DB_VAR_GET)
*valuep = rgs();
else
@ -150,8 +180,9 @@ db_ss(struct db_variable *vp, db_expr_t *valuep, int op)
return (0);
if (op == DB_VAR_GET)
*valuep = (ISPL(kdb_frame->tf_cs)) ? kdb_frame->tf_ss : rss();
else if (ISPL(kdb_frame->tf_cs))
*valuep = (ISPL(kdb_frame->tf_cs) ||
kdb_frame->tf_eflags & PSL_VM) ? kdb_frame->tf_ss : rss();
else if (ISPL(kdb_frame->tf_cs) || kdb_frame->tf_eflags & PSL_VM)
kdb_frame->tf_ss = *valuep;
return (1);
}

View File

@ -35,7 +35,10 @@
typedef vm_offset_t db_addr_t; /* address - unsigned */
typedef int db_expr_t; /* expression - signed */
#define PC_REGS() ((db_addr_t)kdb_thrctx->pcb_eip)
#define PC_REGS() ((db_addr_t)(kdb_frame->tf_eflags & PSL_VM ? \
(kdb_frame->tf_eip & 0xffff) + \
((kdb_frame->tf_cs & 0xffff) << 4) : \
kdb_frame->tf_eip))
#define BKPT_INST 0xcc /* breakpoint instruction */
#define BKPT_SIZE (1) /* size of breakpoint inst */

View File

@ -354,8 +354,8 @@ show_pcpu(struct pcpu *pc)
db_printf("curthread = ");
td = pc->pc_curthread;
if (td != NULL)
db_printf("%p: pid %d \"%s\"\n", td, td->td_proc->p_pid,
td->td_name);
db_printf("%p: pid %d tid %d \"%s\"\n", td, td->td_proc->p_pid,
td->td_tid, td->td_name);
else
db_printf("none\n");
db_printf("curpcb = %p\n", pc->pc_curpcb);

View File

@ -358,10 +358,10 @@ mpc85xx_map_dcsr(void)
* Find the node the long way.
*/
if ((node = OF_finddevice("/")) == -1)
return (ENXIO);
return (0);
if ((node = ofw_bus_find_compatible(node, "fsl,dcsr")) == 0)
return (ENXIO);
return (0);
moveon:
err = fdt_get_range(node, 0, &b, &s);

View File

@ -404,7 +404,7 @@ mpc85xx_smp_start_cpu(platform_t plat, struct pcpu *pc)
* bp_kernload is in the boot page. Sync the cache because ePAPR
* booting has the other core(s) already running.
*/
__syncicache(&bp_kernload, sizeof(bp_kernload));
cpu_flush_dcache(&bp_kernload, sizeof(bp_kernload));
ap_pcpu = pc;
__asm __volatile("msync; isync");

View File

@ -331,8 +331,8 @@
08/13 Proclamation of Independence in Central African Republic
08/13 Women's Day in Tunisia
08/14 Independence Day in Pakistan
08/14 VJ Day, 1945
08/14 Waddi Dhahab in Morocco
08/15 VJ Day, 1945
08/15 Founding of Ascuncion in Paraguay
08/15 Independence Day in India
08/15 Liberation Day in South Korea

View File

@ -4,4 +4,6 @@
PROG= nfsstat
CFLAGS+=-DNFS
LIBADD+= devstat
.include <bsd.prog.mk>