Merge ^/head r317503 through r317807.

This commit is contained in:
dim 2017-05-04 21:30:26 +00:00
commit d7242252fe
282 changed files with 17713 additions and 2545 deletions

View File

@ -150,9 +150,7 @@ OLD_FILES+=usr/lib/clang/4.0.0/lib/freebsd/libclang_rt.ubsan_standalone_cxx-x86_
OLD_DIRS+=usr/lib/clang/4.0.0/lib/freebsd
OLD_DIRS+=usr/lib/clang/4.0.0/lib
OLD_DIRS+=usr/lib/clang/4.0.0
# 20170426: Remove cy(4)
OLD_FILES+=usr/share/man/man4/cy.4.gz
# 20170425: NATM configuration support removed
# 20170427: NATM configuration support removed
OLD_FILES+=etc/rc.d/atm1
OLD_FILES+=etc/rc.d/atm2
OLD_FILES+=etc/rc.d/atm3
@ -190,6 +188,7 @@ OLD_FILES+=usr/share/man/man4/ng_atm.4.gz
OLD_FILES+=usr/share/man/man4/patm.4.gz
OLD_FILES+=usr/share/man/man4/utopia.4.gz
OLD_FILES+=usr/share/man/man8/atmconfig.8.gz
OLD_FILES+=usr/share/man/man9/utopia.9.gz
OLD_FILES+=usr/share/snmp/defs/atm_freebsd.def
OLD_FILES+=usr/share/snmp/defs/atm_tree.def
OLD_FILES+=usr/share/snmp/mibs/BEGEMOT-ATM-FREEBSD-MIB.txt

View File

@ -462,6 +462,7 @@ expbackq(union node *cmd, int quoted, int flag, struct worddest *dst)
int quotes = flag & (EXP_GLOB | EXP_CASE);
size_t nnl;
const char *ifs;
int startloc;
INTOFF;
p = grabstackstr(dest);
@ -469,6 +470,7 @@ expbackq(union node *cmd, int quoted, int flag, struct worddest *dst)
ungrabstackstr(p, dest);
p = in.buf;
startloc = dest - stackblock();
nnl = 0;
if (!quoted && flag & EXP_SPLIT)
ifs = ifsset() ? ifsval() : " \t\n";
@ -490,31 +492,24 @@ expbackq(union node *cmd, int quoted, int flag, struct worddest *dst)
lastc = *p++;
if (lastc == '\0')
continue;
if (lastc == '\n') {
nnl++;
} else {
if (nnl > 0) {
if (strchr(ifs, '\n') != NULL) {
NEXTWORD('\n', flag, dest, dst);
nnl = 0;
} else {
CHECKSTRSPACE(nnl + 2, dest);
while (nnl > 0) {
nnl--;
USTPUTC('\n', dest);
}
}
}
if (strchr(ifs, lastc) != NULL)
if (nnl > 0 && lastc != '\n') {
NEXTWORD('\n', flag, dest, dst);
nnl = 0;
}
if (strchr(ifs, lastc) != NULL) {
if (lastc == '\n')
nnl++;
else
NEXTWORD(lastc, flag, dest, dst);
else {
CHECKSTRSPACE(2, dest);
if (quotes && syntax[(int)lastc] == CCTL)
USTPUTC(CTLESC, dest);
USTPUTC(lastc, dest);
}
} else {
CHECKSTRSPACE(2, dest);
if (quotes && syntax[(int)lastc] == CCTL)
USTPUTC(CTLESC, dest);
USTPUTC(lastc, dest);
}
}
while (dest > stackblock() + startloc && STTOPC(dest) == '\n')
STUNPUTC(dest);
if (in.fd >= 0)
close(in.fd);

View File

@ -46,6 +46,8 @@ ${PACKAGE}FILES+= cmdsubst21.0
${PACKAGE}FILES+= cmdsubst22.0
${PACKAGE}FILES+= cmdsubst23.0
${PACKAGE}FILES+= cmdsubst24.0
${PACKAGE}FILES+= cmdsubst25.0
${PACKAGE}FILES+= cmdsubst26.0
${PACKAGE}FILES+= export1.0
${PACKAGE}FILES+= export2.0
${PACKAGE}FILES+= export3.0

View File

@ -0,0 +1,7 @@
# $FreeBSD$
IFS=' '
set -- `printf '\n '`
IFS=:
[ "$*" = '
' ]

View File

@ -0,0 +1,6 @@
# $FreeBSD$
nl='
'
v=$nl`printf '\n'`
[ "$v" = "$nl" ]

View File

@ -1,4 +1,4 @@
# $NetBSD: README,v 1.7 2015/01/26 00:34:50 christos Exp $
# $NetBSD: README,v 1.8 2017/04/13 17:59:34 christos Exp $
This package contains library that can be used by network daemons to
communicate with a packet filter via a daemon to enforce opening and
@ -98,6 +98,16 @@ group "internal" on $int_if {
...
}
You can use 'blacklistctl dump -a' to list all the current entries
in the database; the ones that have nfail <c>/<t> where <c>urrent
>= <t>otal, should have an id assosiated with them; this means that
there is a packet filter rule added for that entry. For npf, you
can examine the packet filter dynamic rule entries using 'npfctl
rule <rulename> list'. The number of current entries can exceed
the total. This happens because entering packet filter rules is
asynchronous; there could be other connection before the rule
becomes activated.
Enjoy,
christos

View File

@ -1,4 +1,4 @@
.\" $NetBSD: blacklistctl.8,v 1.7 2015/04/30 06:20:43 riz Exp $
.\" $NetBSD: blacklistctl.8,v 1.9 2016/06/08 12:48:37 wiz Exp $
.\"
.\" Copyright (c) 2015 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -77,7 +77,8 @@ it to make sure that there is only one rule active.
.Nm
first appeared in
.Nx 7 .
.Fx support for
.Fx
support for
.Nm
was implemented in
.Fx 11 .

View File

@ -1,4 +1,4 @@
/* $NetBSD: blacklistctl.c,v 1.20 2016/04/04 15:52:56 christos Exp $ */
/* $NetBSD: blacklistctl.c,v 1.21 2016/11/02 03:15:07 jnemeth Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@ -33,7 +33,7 @@
#endif
#include <sys/cdefs.h>
__RCSID("$NetBSD: blacklistctl.c,v 1.20 2016/04/04 15:52:56 christos Exp $");
__RCSID("$NetBSD: blacklistctl.c,v 1.21 2016/11/02 03:15:07 jnemeth Exp $");
#include <stdio.h>
#include <time.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: blacklistd.c,v 1.35 2016/09/26 19:43:43 christos Exp $ */
/* $NetBSD: blacklistd.c,v 1.37 2017/02/18 00:26:16 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@ -32,7 +32,7 @@
#include "config.h"
#endif
#include <sys/cdefs.h>
__RCSID("$NetBSD: blacklistd.c,v 1.35 2016/09/26 19:43:43 christos Exp $");
__RCSID("$NetBSD: blacklistd.c,v 1.37 2017/02/18 00:26:16 christos Exp $");
#include <sys/types.h>
#include <sys/socket.h>
@ -403,12 +403,14 @@ int
main(int argc, char *argv[])
{
int c, tout, flags, flush, restore, ret;
const char *spath, *blsock;
const char *spath, **blsock;
size_t nblsock, maxblsock;
setprogname(argv[0]);
spath = NULL;
blsock = _PATH_BLSOCK;
blsock = NULL;
maxblsock = nblsock = 0;
flush = 0;
restore = 0;
tout = 0;
@ -440,7 +442,17 @@ main(int argc, char *argv[])
restore++;
break;
case 's':
blsock = optarg;
if (nblsock >= maxblsock) {
maxblsock += 10;
void *p = realloc(blsock,
sizeof(*blsock) * maxblsock);
if (p == NULL)
err(EXIT_FAILURE,
"Can't allocate memory for %zu sockets",
maxblsock);
blsock = p;
}
blsock[nblsock++] = optarg;
break;
case 't':
tout = atoi(optarg) * 1000;
@ -487,9 +499,11 @@ main(int argc, char *argv[])
size_t nfd = 0;
size_t maxfd = 0;
if (spath == NULL)
addfd(&pfd, &bl, &nfd, &maxfd, blsock);
else {
for (size_t i = 0; i < nblsock; i++)
addfd(&pfd, &bl, &nfd, &maxfd, blsock[i]);
free(blsock);
if (spath) {
FILE *fp = fopen(spath, "r");
char *line;
if (fp == NULL)
@ -499,6 +513,8 @@ main(int argc, char *argv[])
addfd(&pfd, &bl, &nfd, &maxfd, line);
fclose(fp);
}
if (nfd == 0)
addfd(&pfd, &bl, &nfd, &maxfd, _PATH_BLSOCK);
state = state_open(dbfile, flags, 0600);
if (state == NULL)

View File

@ -1,4 +1,4 @@
.\" $NetBSD: blacklistd.conf.5,v 1.3 2015/04/30 06:20:43 riz Exp $
.\" $NetBSD: blacklistd.conf.5,v 1.5 2016/06/08 12:48:37 wiz Exp $
.\"
.\" Copyright (c) 2015 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -218,7 +218,8 @@ bnx0:ssh * * * * 3 6h
.Nm
first appeared in
.Nx 7 .
.Fx support for
.Fx
support for
.Nm
was implemented in
.Fx 11 .

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# $NetBSD: blacklistd,v 1.1 2015/01/22 17:49:41 christos Exp $
# $NetBSD: blacklistd,v 1.2 2016/10/17 22:47:16 christos Exp $
#
# PROVIDE: blacklistd
@ -18,7 +18,7 @@ start_precmd="${name}_precmd"
extra_commands="reload"
_sockfile="/var/run/${name}.sockets"
_sockname="blsock"
_sockname="blacklistd.sock"
blacklistd_precmd()
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: bl.c,v 1.27 2015/12/30 16:42:48 christos Exp $ */
/* $NetBSD: bl.c,v 1.28 2016/07/29 17:13:09 christos Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@ -33,7 +33,7 @@
#endif
#include <sys/cdefs.h>
__RCSID("$NetBSD: bl.c,v 1.27 2015/12/30 16:42:48 christos Exp $");
__RCSID("$NetBSD: bl.c,v 1.28 2016/07/29 17:13:09 christos Exp $");
#include <sys/param.h>
#include <sys/types.h>

View File

@ -1,4 +1,4 @@
.\" $NetBSD: libblacklist.3,v 1.3 2015/01/25 23:09:28 wiz Exp $
.\" $NetBSD: libblacklist.3,v 1.7 2017/02/04 23:33:56 wiz Exp $
.\"
.\" Copyright (c) 2015 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -36,7 +36,7 @@
.Nm blacklist_r ,
.Nm blacklist ,
.Nm blacklist_sa
.Nm blacklist_sa_r ,
.Nm blacklist_sa_r
.Nd Blacklistd notification library
.Sh LIBRARY
.Lb libblacklist
@ -62,7 +62,7 @@ block or release port access to prevent Denial of Service attacks.
.Pp
The function
.Fn blacklist_open
creates a the necessary state to communicate with
creates the necessary state to communicate with
.Xr blacklistd 8
and returns a pointer to it, or
.Dv NULL
@ -106,18 +106,25 @@ All functions log errors to
.Xr syslogd 8 .
.Sh RETURN VALUES
The function
.Fn bl_open
.Fn blacklist_open
returns a cookie on success and
.Dv NULL
on failure setting errno to an appropriate value.
on failure setting
.Dv errno
to an appropriate value.
.Pp
The
.Fn bl_send
function returns
The functions
.Fn blacklist ,
.Fn blacklist_sa ,
and
.Fn blacklist_sa_r
return
.Dv 0
on success and
.Dv -1
on failure setting errno to an appropriate value.
.Dv \-1
on failure setting
.Dv errno
to an appropriate value.
.Sh SEE ALSO
.Xr blacklistd.conf 5 ,
.Xr blacklistd 8

View File

@ -19,8 +19,8 @@ fi
if [ -z "$pf" ]; then
for f in npf pf ipf; do
if [ -f "/etc/$f.conf" ]; then
pf="$f"
break
pf="$f"
break
fi
done
fi

View File

@ -1,11 +1,11 @@
#
ACLOCAL_AMFLAGS = -I m4
lib_LTLIBRARIES = libblacklist.la
include_HEADERS = blacklist.h
include_HEADERS = ../include/blacklist.h
bin_PROGRAMS = blacklistd blacklistctl srvtest cltest
VPATH = ../bin:../lib:../test
VPATH = ../bin:../lib:../test:../include
AM_CPPFLAGS = -I../include -DDOT="."
AM_CFLAGS = @WARNINGS@

View File

@ -1,4 +1,4 @@
/* $NetBSD: sockaddr_snprintf.c,v 1.10 2016/04/05 12:28:57 christos Exp $ */
/* $NetBSD: sockaddr_snprintf.c,v 1.11 2016/06/01 22:57:51 christos Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: sockaddr_snprintf.c,v 1.10 2016/04/05 12:28:57 christos Exp $");
__RCSID("$NetBSD: sockaddr_snprintf.c,v 1.11 2016/06/01 22:57:51 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@ -219,7 +219,7 @@ sockaddr_snprintf(char * const sbuf, const size_t len, const char * const fmt,
case AF_LINK:
sdl = ((const struct sockaddr_dl *)(const void *)sa);
(void)strlcpy(addr = abuf, link_ntoa(sdl), sizeof(abuf));
if ((w = strchr(addr, ':')) != 0) {
if ((w = strchr(addr, ':')) != NULL) {
*w++ = '\0';
addr = w;
}

View File

@ -189,8 +189,6 @@ main(int argc, char **argv)
if (c == EOF)
break;
putchar(c);
if (c == '\n')
fflush(stdout);
} else {
if ((size_t) p >= sizeof(buf) - 1)
warnx("buffer overflowed");

View File

@ -61,6 +61,10 @@ typedef uint16_t __u16;
typedef uint32_t __u32;
typedef uint64_t __u64;
#define POOL_FILE_MODE (S_IRUSR | S_IWUSR)
#define POOL_DIR_MODE (POOL_FILE_MODE | S_IXUSR)
#define POOL_DIR "/var/db/hyperv/pool"
/*
* ENUM Data
*/
@ -285,11 +289,12 @@ kvp_file_init(void)
int i;
int alloc_unit = sizeof(struct kvp_record) * ENTRIES_PER_BLOCK;
if (mkdir("/var/db/hyperv/pool", S_IRUSR | S_IWUSR | S_IROTH) < 0 &&
if (mkdir(POOL_DIR, POOL_DIR_MODE) < 0 &&
(errno != EEXIST && errno != EISDIR)) {
KVP_LOG(LOG_ERR, " Failed to create /var/db/hyperv/pool\n");
exit(EXIT_FAILURE);
}
chmod(POOL_DIR, POOL_DIR_MODE); /* fix old mistake */
for (i = 0; i < HV_KVP_POOL_COUNT; i++)
{
@ -297,11 +302,12 @@ kvp_file_init(void)
records_read = 0;
num_blocks = 1;
snprintf(fname, MAX_FILE_NAME, "/var/db/hyperv/pool/.kvp_pool_%d", i);
fd = open(fname, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IROTH);
fd = open(fname, O_RDWR | O_CREAT, POOL_FILE_MODE);
if (fd == -1) {
return (1);
}
fchmod(fd, POOL_FILE_MODE); /* fix old mistake */
filep = fopen(fname, "r");

View File

@ -628,6 +628,7 @@ mode_out(struct cpio *cpio)
blocks == 1 ? "block" : "blocks");
}
archive_write_free(cpio->archive);
archive_entry_linkresolver_free(cpio->linkresolver);
}
static const char *
@ -1194,12 +1195,15 @@ mode_pass(struct cpio *cpio, const char *destdir)
struct lafe_line_reader *lr;
const char *p;
int r;
size_t destdir_len;
/* Ensure target dir has a trailing '/' to simplify path surgery. */
cpio->destdir = malloc(strlen(destdir) + 8);
strcpy(cpio->destdir, destdir);
if (destdir[strlen(destdir) - 1] != '/')
strcat(cpio->destdir, "/");
destdir_len = strlen(destdir);
cpio->destdir = malloc(destdir_len + 8);
memcpy(cpio->destdir, destdir, destdir_len);
if (destdir_len == 0 || destdir[destdir_len - 1] != '/')
cpio->destdir[destdir_len++] = '/';
cpio->destdir[destdir_len++] = '\0';
cpio->archive = archive_write_disk_new();
if (cpio->archive == NULL)
@ -1240,6 +1244,7 @@ mode_pass(struct cpio *cpio, const char *destdir)
}
archive_write_free(cpio->archive);
free(cpio->pass_destpath);
}
/*

View File

@ -43,17 +43,18 @@ DEFINE_TEST(test_option_Z_upper)
if (strstr(p, "compression not available") != NULL) {
skipping("This version of bsdcpio was compiled "
"without compress support");
free(p);
return;
}
failure("-Z option is broken");
assertEqualInt(r, 0);
goto done;
free(p);
return;
}
free(p);
/* Check that the archive file has a compress signature. */
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "\x1f\x9d", 2);
done:
free(p);
}

View File

@ -96,7 +96,8 @@ DEFINE_TEST(test_option_a)
test_create();
/* Sanity check; verify that atimes really do get modified. */
assert((p = slurpfile(NULL, "f0")) != NULL);
p = slurpfile(NULL, "f0");
assert(p != NULL);
free(p);
assertEqualInt(0, stat("f0", &st));
if (st.st_atime == files[0].atime_sec) {

View File

@ -42,6 +42,7 @@ DEFINE_TEST(test_option_b64encode)
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "begin-base64 644", 16);
free(p);
/* Archive it with uuencode only. */
assertEqualInt(0,
@ -51,4 +52,5 @@ DEFINE_TEST(test_option_b64encode)
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "begin-base64 644", 16);
free(p);
}

View File

@ -44,9 +44,10 @@ DEFINE_TEST(test_option_grzip)
systemf("echo f | %s -o --grzip >archive.out 2>archive.err",
testprog));
p = slurpfile(&s, "archive.err");
p[s] = '\0';
free(p);
/* Check that the archive file has an grzip signature. */
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "GRZipII\x00\x02\x04:)", 12);
free(p);
}

View File

@ -44,9 +44,10 @@ DEFINE_TEST(test_option_lrzip)
systemf("echo f | %s -o --lrzip >archive.out 2>archive.err",
testprog));
p = slurpfile(&s, "archive.err");
p[s] = '\0';
free(p);
/* Check that the archive file has an lzma signature. */
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "LRZI\x00", 5);
free(p);
}

View File

@ -43,6 +43,7 @@ DEFINE_TEST(test_option_lz4)
if (strstr(p, "compression not available") != NULL) {
skipping("This version of bsdcpio was compiled "
"without lz4 support");
free(p);
return;
}
/* POSIX permits different handling of the spawnp
@ -52,6 +53,7 @@ DEFINE_TEST(test_option_lz4)
if (strstr(p, "Can't launch") != NULL && !canLz4()) {
skipping("This version of bsdcpio uses an external lz4 program "
"but no such program is available on this system.");
free(p);
return;
}
/* Some systems successfully spawn the new process,
@ -61,6 +63,7 @@ DEFINE_TEST(test_option_lz4)
if (strstr(p, "Can't write") != NULL && !canLz4()) {
skipping("This version of bsdcpio uses an external lz4 program "
"but no such program is available on this system.");
free(p);
return;
}
/* On some systems the error won't be detected until closing
@ -68,14 +71,18 @@ DEFINE_TEST(test_option_lz4)
if (strstr(p, "Error closing") != NULL && !canLz4()) {
skipping("This version of bsdcpio uses an external lz4 program "
"but no such program is available on this system.");
free(p);
return;
}
free(p);
failure("--lz4 option is broken: %s", p);
assertEqualInt(r, 0);
return;
}
free(p);
/* Check that the archive file has an lz4 signature. */
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "\x04\x22\x4d\x18", 4);
free(p);
}

View File

@ -43,14 +43,18 @@ DEFINE_TEST(test_option_lzma)
if (strstr(p, "compression not available") != NULL) {
skipping("This version of bsdcpio was compiled "
"without lzma support");
free(p);
return;
}
failure("--lzma option is broken");
assertEqualInt(r, 0);
free(p);
return;
}
free(p);
/* Check that the archive file has an lzma signature. */
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "\x5d\00\00", 3);
free(p);
}

View File

@ -39,7 +39,7 @@ DEFINE_TEST(test_option_lzop)
r = systemf("echo f | %s -o --lzop >archive.out 2>archive.err",
testprog);
p = slurpfile(&s, "archive.err");
p[s] = '\0';
free(p);
if (r != 0) {
if (!canLzop()) {
skipping("lzop is not supported on this platform");
@ -53,4 +53,5 @@ DEFINE_TEST(test_option_lzop)
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "\x89\x4c\x5a\x4f\x00\x0d\x0a\x1a\x0a", 9);
free(p);
}

View File

@ -42,6 +42,7 @@ DEFINE_TEST(test_option_uuencode)
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "begin 644", 9);
free(p);
/* Archive it with uuencode only. */
assertEqualInt(0,
@ -51,4 +52,5 @@ DEFINE_TEST(test_option_uuencode)
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "begin 644", 9);
free(p);
}

View File

@ -44,14 +44,18 @@ DEFINE_TEST(test_option_xz)
if (strstr(p, "compression not available") != NULL) {
skipping("This version of bsdcpio was compiled "
"without xz support");
free(p);
return;
}
free(p);
failure("--xz option is broken");
assertEqualInt(r, 0);
return;
}
free(p);
/* Check that the archive file has an xz signature. */
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "\xFD\x37\x7A\x58\x5A\x00", 6);
free(p);
}

View File

@ -38,7 +38,7 @@ DEFINE_TEST(test_option_y)
r = systemf("echo f | %s -oy >archive.out 2>archive.err",
testprog);
p = slurpfile(&s, "archive.err");
p[s] = '\0';
free(p);
if (r != 0) {
if (!canBzip2()) {
skipping("bzip2 is not supported on this platform");
@ -46,14 +46,12 @@ DEFINE_TEST(test_option_y)
}
failure("-y option is broken");
assertEqualInt(r, 0);
goto done;
return;
}
assertTextFileContents("1 block\n", "archive.err");
/* Check that the archive file has a bzip2 signature. */
free(p);
p = slurpfile(&s, "archive.out");
assert(s > 2);
assertEqualMem(p, "BZh9", 4);
done:
free(p);
}

View File

@ -38,7 +38,7 @@ DEFINE_TEST(test_option_z)
r = systemf("echo f | %s -oz >archive.out 2>archive.err",
testprog);
p = slurpfile(&s, "archive.err");
p[s] = '\0';
free(p);
if (r != 0) {
if (!canGzip()) {
skipping("gzip is not supported on this platform");
@ -52,4 +52,5 @@ DEFINE_TEST(test_option_z)
p = slurpfile(&s, "archive.out");
assert(s > 4);
assertEqualMem(p, "\x1f\x8b\x08\x00", 4);
free(p);
}

View File

@ -51,7 +51,7 @@ archive_entry_sparse_clear(struct archive_entry *entry)
void
archive_entry_sparse_add_entry(struct archive_entry *entry,
int64_t offset, int64_t length)
la_int64_t offset, la_int64_t length)
{
struct ae_sparse *sp;
@ -135,7 +135,7 @@ archive_entry_sparse_reset(struct archive_entry * entry)
int
archive_entry_sparse_next(struct archive_entry * entry,
int64_t *offset, int64_t *length)
la_int64_t *offset, la_int64_t *length)
{
if (entry->sparse_p) {
*offset = entry->sparse_p->offset;

View File

@ -691,7 +691,7 @@ Convert(time_t Month, time_t Day, time_t Year,
time_t Hours, time_t Minutes, time_t Seconds,
time_t Timezone, enum DSTMODE DSTmode)
{
int DaysInMonth[12] = {
signed char DaysInMonth[12] = {
31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
time_t Julian;

View File

@ -28,7 +28,7 @@
#include <openssl/hmac.h>
#include <openssl/opensslv.h>
#if OPENSSL_VERSION_NUMBER < 0x10100000L
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
#include <stdlib.h> /* malloc, free */
#include <string.h> /* memset */
static inline HMAC_CTX *HMAC_CTX_new(void)

View File

@ -881,7 +881,8 @@ archive_read_data(struct archive *_a, void *buff, size_t s)
len = a->read_data_remaining;
if (len > s)
len = s;
memcpy(dest, a->read_data_block, len);
if (len)
memcpy(dest, a->read_data_block, len);
s -= len;
a->read_data_block += len;
a->read_data_remaining -= len;

View File

@ -928,11 +928,10 @@ setup_sparse(struct archive_read_disk *a,
return (ARCHIVE_OK);
/* Does filesystem support the reporting of hole ? */
if (*fd < 0) {
if (*fd < 0)
path = archive_read_disk_entry_setup_path(a, entry, fd);
if (path == NULL)
return (ARCHIVE_FAILED);
}
else
path = NULL;
if (*fd >= 0) {
#ifdef _PC_MIN_HOLE_SIZE
@ -943,6 +942,8 @@ setup_sparse(struct archive_read_disk *a,
if (initial_off != 0)
lseek(*fd, 0, SEEK_SET);
} else {
if (path == NULL)
return (ARCHIVE_FAILED);
#ifdef _PC_MIN_HOLE_SIZE
if (pathconf(path, _PC_MIN_HOLE_SIZE) <= 0)
return (ARCHIVE_OK);

View File

@ -494,7 +494,7 @@ lz4_filter_read_data_block(struct archive_read_filter *self, const void **p)
if (read_buf == NULL)
goto truncated_error;
compressed_size = archive_le32dec(read_buf);
if ((compressed_size & ~(1 << 31)) > state->flags.block_maximum_size)
if ((compressed_size & 0x7fffffff) > state->flags.block_maximum_size)
goto malformed_error;
/* A compressed size == 0 means the end of stream blocks. */
if (compressed_size == 0) {
@ -504,8 +504,8 @@ lz4_filter_read_data_block(struct archive_read_filter *self, const void **p)
checksum_size = state->flags.block_checksum;
/* Check if the block is uncompressed. */
if (compressed_size & (1 << 31)) {
compressed_size &= ~(1 << 31);
if (compressed_size & 0x80000000U) {
compressed_size &= 0x7fffffff;
uncompressed_size = compressed_size;
} else
uncompressed_size = 0;/* Unknown yet. */

View File

@ -116,19 +116,11 @@ struct lzx_dec {
* coding tree, which is a binary tree. But a use of a large
* index table causes L1 cache read miss many times.
*/
#define HTBL_BITS 10
int max_bits;
int shift_bits;
int tbl_bits;
int tree_used;
int tree_avail;
/* Direct access table. */
uint16_t *tbl;
/* Binary tree table for extra bits over the direct access. */
struct htree_t {
uint16_t left;
uint16_t right;
} *tree;
} at, lt, mt, pt;
int loop;
@ -352,7 +344,6 @@ static int lzx_huffman_init(struct huffman *, size_t, int);
static void lzx_huffman_free(struct huffman *);
static int lzx_make_huffman_table(struct huffman *);
static inline int lzx_decode_huffman(struct huffman *, unsigned);
static int lzx_decode_huffman_tree(struct huffman *, unsigned, int);
int
@ -3127,7 +3118,6 @@ lzx_read_bitlen(struct lzx_stream *strm, struct huffman *d, int end)
static int
lzx_huffman_init(struct huffman *hf, size_t len_size, int tbl_bits)
{
int bits;
if (hf->bitlen == NULL || hf->len_size != (int)len_size) {
free(hf->bitlen);
@ -3138,21 +3128,11 @@ lzx_huffman_init(struct huffman *hf, size_t len_size, int tbl_bits)
} else
memset(hf->bitlen, 0, len_size * sizeof(hf->bitlen[0]));
if (hf->tbl == NULL) {
if (tbl_bits < HTBL_BITS)
bits = tbl_bits;
else
bits = HTBL_BITS;
hf->tbl = malloc(((size_t)1 << bits) * sizeof(hf->tbl[0]));
hf->tbl = malloc(((size_t)1 << tbl_bits) * sizeof(hf->tbl[0]));
if (hf->tbl == NULL)
return (ARCHIVE_FATAL);
hf->tbl_bits = tbl_bits;
}
if (hf->tree == NULL && tbl_bits > HTBL_BITS) {
hf->tree_avail = 1 << (tbl_bits - HTBL_BITS + 4);
hf->tree = malloc(hf->tree_avail * sizeof(hf->tree[0]));
if (hf->tree == NULL)
return (ARCHIVE_FATAL);
}
return (ARCHIVE_OK);
}
@ -3161,7 +3141,6 @@ lzx_huffman_free(struct huffman *hf)
{
free(hf->bitlen);
free(hf->tbl);
free(hf->tree);
}
/*
@ -3174,7 +3153,7 @@ lzx_make_huffman_table(struct huffman *hf)
const unsigned char *bitlen;
int bitptn[17], weight[17];
int i, maxbits = 0, ptn, tbl_size, w;
int diffbits, len_avail;
int len_avail;
/*
* Initialize bit patterns.
@ -3205,28 +3184,11 @@ lzx_make_huffman_table(struct huffman *hf)
weight[i] >>= ebits;
}
}
if (maxbits > HTBL_BITS) {
int htbl_max;
uint16_t *p;
diffbits = maxbits - HTBL_BITS;
for (i = 1; i <= HTBL_BITS; i++) {
bitptn[i] >>= diffbits;
weight[i] >>= diffbits;
}
htbl_max = bitptn[HTBL_BITS] +
weight[HTBL_BITS] * hf->freq[HTBL_BITS];
p = &(hf->tbl[htbl_max]);
while (p < &hf->tbl[1U<<HTBL_BITS])
*p++ = 0;
} else
diffbits = 0;
hf->shift_bits = diffbits;
/*
* Make the table.
*/
tbl_size = 1 << HTBL_BITS;
tbl_size = 1 << hf->tbl_bits;
tbl = hf->tbl;
bitlen = hf->bitlen;
len_avail = hf->len_size;
@ -3234,120 +3196,32 @@ lzx_make_huffman_table(struct huffman *hf)
for (i = 0; i < len_avail; i++) {
uint16_t *p;
int len, cnt;
uint16_t bit;
int extlen;
struct htree_t *ht;
if (bitlen[i] == 0)
continue;
/* Get a bit pattern */
len = bitlen[i];
if (len > tbl_size)
return (0);
ptn = bitptn[len];
cnt = weight[len];
if (len <= HTBL_BITS) {
/* Calculate next bit pattern */
if ((bitptn[len] = ptn + cnt) > tbl_size)
return (0);/* Invalid */
/* Update the table */
p = &(tbl[ptn]);
while (--cnt >= 0)
p[cnt] = (uint16_t)i;
continue;
}
/*
* A bit length is too big to be housed to a direct table,
* so we use a tree model for its extra bits.
*/
bitptn[len] = ptn + cnt;
bit = 1U << (diffbits -1);
extlen = len - HTBL_BITS;
p = &(tbl[ptn >> diffbits]);
if (*p == 0) {
*p = len_avail + hf->tree_used;
ht = &(hf->tree[hf->tree_used++]);
if (hf->tree_used > hf->tree_avail)
return (0);/* Invalid */
ht->left = 0;
ht->right = 0;
} else {
if (*p < len_avail ||
*p >= (len_avail + hf->tree_used))
return (0);/* Invalid */
ht = &(hf->tree[*p - len_avail]);
}
while (--extlen > 0) {
if (ptn & bit) {
if (ht->left < len_avail) {
ht->left = len_avail + hf->tree_used;
ht = &(hf->tree[hf->tree_used++]);
if (hf->tree_used > hf->tree_avail)
return (0);/* Invalid */
ht->left = 0;
ht->right = 0;
} else {
ht = &(hf->tree[ht->left - len_avail]);
}
} else {
if (ht->right < len_avail) {
ht->right = len_avail + hf->tree_used;
ht = &(hf->tree[hf->tree_used++]);
if (hf->tree_used > hf->tree_avail)
return (0);/* Invalid */
ht->left = 0;
ht->right = 0;
} else {
ht = &(hf->tree[ht->right - len_avail]);
}
}
bit >>= 1;
}
if (ptn & bit) {
if (ht->left != 0)
return (0);/* Invalid */
ht->left = (uint16_t)i;
} else {
if (ht->right != 0)
return (0);/* Invalid */
ht->right = (uint16_t)i;
}
/* Calculate next bit pattern */
if ((bitptn[len] = ptn + cnt) > tbl_size)
return (0);/* Invalid */
/* Update the table */
p = &(tbl[ptn]);
while (--cnt >= 0)
p[cnt] = (uint16_t)i;
}
return (1);
}
static int
lzx_decode_huffman_tree(struct huffman *hf, unsigned rbits, int c)
{
struct htree_t *ht;
int extlen;
ht = hf->tree;
extlen = hf->shift_bits;
while (c >= hf->len_size) {
c -= hf->len_size;
if (extlen-- <= 0 || c >= hf->tree_used)
return (0);
if (rbits & (1U << extlen))
c = ht[c].left;
else
c = ht[c].right;
}
return (c);
}
static inline int
lzx_decode_huffman(struct huffman *hf, unsigned rbits)
{
int c;
/*
* At first search an index table for a bit pattern.
* If it fails, search a huffman tree for.
*/
c = hf->tbl[rbits >> hf->shift_bits];
c = hf->tbl[rbits];
if (c < hf->len_size)
return (c);
/* This bit pattern needs to be found out at a huffman tree. */
return (lzx_decode_huffman_tree(hf, rbits, c));
return (0);
}

View File

@ -165,7 +165,7 @@ __FBSDID("$FreeBSD$");
struct links_entry {
struct links_entry *next;
struct links_entry *previous;
int links;
unsigned int links;
dev_t dev;
int64_t ino;
char *name;

View File

@ -3021,8 +3021,9 @@ heap_add_entry(struct archive_read *a, struct heap_queue *heap,
ENOMEM, "Out of memory");
return (ARCHIVE_FATAL);
}
memcpy(new_pending_files, heap->files,
heap->allocated * sizeof(new_pending_files[0]));
if (heap->allocated)
memcpy(new_pending_files, heap->files,
heap->allocated * sizeof(new_pending_files[0]));
if (heap->files != NULL)
free(heap->files);
heap->files = new_pending_files;

View File

@ -130,9 +130,7 @@ static ssize_t readline(struct archive_read *, struct mtree *, char **, ssize_t)
static int skip(struct archive_read *a);
static int read_header(struct archive_read *,
struct archive_entry *);
static int64_t mtree_atol10(char **);
static int64_t mtree_atol8(char **);
static int64_t mtree_atol(char **);
static int64_t mtree_atol(char **, int base);
/*
* There's no standard for TIME_T_MAX/TIME_T_MIN. So we compute them
@ -1418,7 +1416,7 @@ parse_device(dev_t *pdev, struct archive *a, char *val)
"Too many arguments");
return ARCHIVE_WARN;
}
numbers[argc++] = (unsigned long)mtree_atol(&p);
numbers[argc++] = (unsigned long)mtree_atol(&p, 0);
}
if (argc < 2) {
archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,
@ -1433,7 +1431,7 @@ parse_device(dev_t *pdev, struct archive *a, char *val)
}
} else {
/* file system raw value. */
result = (dev_t)mtree_atol(&val);
result = (dev_t)mtree_atol(&val, 0);
}
*pdev = result;
return ARCHIVE_OK;
@ -1513,7 +1511,7 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
case 'g':
if (strcmp(key, "gid") == 0) {
*parsed_kws |= MTREE_HAS_GID;
archive_entry_set_gid(entry, mtree_atol10(&val));
archive_entry_set_gid(entry, mtree_atol(&val, 10));
break;
}
if (strcmp(key, "gname") == 0) {
@ -1523,7 +1521,7 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
}
case 'i':
if (strcmp(key, "inode") == 0) {
archive_entry_set_ino(entry, mtree_atol10(&val));
archive_entry_set_ino(entry, mtree_atol(&val, 10));
break;
}
case 'l':
@ -1535,14 +1533,14 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
if (strcmp(key, "md5") == 0 || strcmp(key, "md5digest") == 0)
break;
if (strcmp(key, "mode") == 0) {
if (val[0] >= '0' && val[0] <= '9') {
if (val[0] >= '0' && val[0] <= '7') {
*parsed_kws |= MTREE_HAS_PERM;
archive_entry_set_perm(entry,
(mode_t)mtree_atol8(&val));
(mode_t)mtree_atol(&val, 8));
} else {
archive_set_error(&a->archive,
ARCHIVE_ERRNO_FILE_FORMAT,
"Symbolic mode \"%s\" unsupported", val);
"Symbolic or non-octal mode \"%s\" unsupported", val);
return ARCHIVE_WARN;
}
break;
@ -1551,7 +1549,7 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
if (strcmp(key, "nlink") == 0) {
*parsed_kws |= MTREE_HAS_NLINK;
archive_entry_set_nlink(entry,
(unsigned int)mtree_atol10(&val));
(unsigned int)mtree_atol(&val, 10));
break;
}
case 'r':
@ -1582,7 +1580,7 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
strcmp(key, "sha512digest") == 0)
break;
if (strcmp(key, "size") == 0) {
archive_entry_set_size(entry, mtree_atol10(&val));
archive_entry_set_size(entry, mtree_atol(&val, 10));
break;
}
case 't':
@ -1601,13 +1599,13 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
long ns = 0;
*parsed_kws |= MTREE_HAS_MTIME;
m = mtree_atol10(&val);
m = mtree_atol(&val, 10);
/* Replicate an old mtree bug:
* 123456789.1 represents 123456789
* seconds and 1 nanosecond. */
if (*val == '.') {
++val;
ns = (long)mtree_atol10(&val);
ns = (long)mtree_atol(&val, 10);
if (ns < 0)
ns = 0;
else if (ns > 999999999)
@ -1670,7 +1668,7 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
case 'u':
if (strcmp(key, "uid") == 0) {
*parsed_kws |= MTREE_HAS_UID;
archive_entry_set_uid(entry, mtree_atol10(&val));
archive_entry_set_uid(entry, mtree_atol(&val, 10));
break;
}
if (strcmp(key, "uname") == 0) {
@ -1825,77 +1823,9 @@ parse_escapes(char *src, struct mtree_entry *mentry)
*dest = '\0';
}
/*
* Note that this implementation does not (and should not!) obey
* locale settings; you cannot simply substitute strtol here, since
* it does obey locale.
*/
static int64_t
mtree_atol8(char **p)
{
int64_t l, limit, last_digit_limit;
int digit, base;
base = 8;
limit = INT64_MAX / base;
last_digit_limit = INT64_MAX % base;
l = 0;
digit = **p - '0';
while (digit >= 0 && digit < base) {
if (l>limit || (l == limit && digit > last_digit_limit)) {
l = INT64_MAX; /* Truncate on overflow. */
break;
}
l = (l * base) + digit;
digit = *++(*p) - '0';
}
return (l);
}
/*
* Note that this implementation does not (and should not!) obey
* locale settings; you cannot simply substitute strtol here, since
* it does obey locale.
*
* Convert the number pointed to by 'p' into a 64-bit signed integer.
* On return, 'p' points to the first non-digit following the number.
* On overflow, the function returns INT64_MIN or INT64_MAX.
*/
static int64_t
mtree_atol10(char **p)
{
const int base = 10;
const int64_t limit = INT64_MAX / base;
const int64_t last_digit_limit = INT64_MAX % base;
int64_t l;
int sign;
if (**p == '-') {
sign = -1;
++(*p);
} else {
sign = 1;
}
l = 0;
while (**p >= '0' && **p < '0' + base) {
int digit = **p - '0';
if (l > limit || (l == limit && digit > last_digit_limit)) {
while (**p >= '0' && **p < '0' + base) {
++(*p);
}
return (sign < 0) ? INT64_MIN : INT64_MAX;
}
l = (l * base) + digit;
++(*p);
}
return (sign < 0) ? -l : l;
}
/* Parse a hex digit. */
static int
parsehex(char c)
parsedigit(char c)
{
if (c >= '0' && c <= '9')
return c - '0';
@ -1913,45 +1843,50 @@ parsehex(char c)
* it does obey locale.
*/
static int64_t
mtree_atol16(char **p)
mtree_atol(char **p, int base)
{
int64_t l, limit, last_digit_limit;
int base, digit, sign;
int64_t l, limit;
int digit, last_digit_limit;
base = 16;
if (base == 0) {
if (**p != '0')
base = 10;
else if ((*p)[1] == 'x' || (*p)[1] == 'X') {
*p += 2;
base = 16;
} else {
base = 8;
}
}
if (**p == '-') {
sign = -1;
limit = ((uint64_t)(INT64_MAX) + 1) / base;
last_digit_limit = ((uint64_t)(INT64_MAX) + 1) % base;
limit = INT64_MIN / base;
last_digit_limit = INT64_MIN % base;
++(*p);
l = 0;
digit = parsedigit(**p);
while (digit >= 0 && digit < base) {
if (l < limit || (l == limit && digit > last_digit_limit))
return INT64_MIN;
l = (l * base) - digit;
digit = parsedigit(*++(*p));
}
return l;
} else {
sign = 1;
limit = INT64_MAX / base;
last_digit_limit = INT64_MAX % base;
}
l = 0;
digit = parsehex(**p);
while (digit >= 0 && digit < base) {
if (l > limit || (l == limit && digit > last_digit_limit))
return (sign < 0) ? INT64_MIN : INT64_MAX;
l = (l * base) + digit;
digit = parsehex(*++(*p));
l = 0;
digit = parsedigit(**p);
while (digit >= 0 && digit < base) {
if (l > limit || (l == limit && digit > last_digit_limit))
return INT64_MAX;
l = (l * base) + digit;
digit = parsedigit(*++(*p));
}
return l;
}
return (sign < 0) ? -l : l;
}
static int64_t
mtree_atol(char **p)
{
if (**p != '0')
return mtree_atol10(p);
if ((*p)[1] == 'x' || (*p)[1] == 'X') {
*p += 2;
return mtree_atol16(p);
}
return mtree_atol8(p);
}
/*

View File

@ -1750,7 +1750,7 @@ read_exttime(const char *p, struct rar *rar, const char *endp)
return (-1);
for (j = 0; j < count; j++)
{
rem = ((*p) << 16) | (rem >> 8);
rem = (((unsigned)(unsigned char)*p) << 16) | (rem >> 8);
p++;
}
tm = localtime(&t);

View File

@ -202,7 +202,8 @@ archive_string_append(struct archive_string *as, const char *p, size_t s)
{
if (archive_string_ensure(as, as->length + s + 1) == NULL)
return (NULL);
memmove(as->s + as->length, p, s);
if (s)
memmove(as->s + as->length, p, s);
as->length += s;
as->s[as->length] = 0;
return (as);

View File

@ -1196,8 +1196,12 @@ archive_write_pax_header(struct archive_write *a,
"GNU.sparse.major", 1);
add_pax_attr_int(&(pax->pax_header),
"GNU.sparse.minor", 0);
/*
* Make sure to store the original path, since
* truncation to ustar limit happened already.
*/
add_pax_attr(&(pax->pax_header),
"GNU.sparse.name", entry_name.s);
"GNU.sparse.name", path);
add_pax_attr_int(&(pax->pax_header),
"GNU.sparse.realsize",
archive_entry_size(entry_main));
@ -1650,13 +1654,14 @@ build_pax_attribute_name(char *dest, const char *src)
* GNU PAX Format 1.0 requires the special name, which pattern is:
* <dir>/GNUSparseFile.<pid>/<original file name>
*
* Since reproducable archives are more important, use 0 as pid.
*
* This function is used for only Sparse file, a file type of which
* is regular file.
*/
static char *
build_gnu_sparse_name(char *dest, const char *src)
{
char buff[64];
const char *p;
/* Handle the null filename case. */
@ -1682,15 +1687,9 @@ build_gnu_sparse_name(char *dest, const char *src)
break;
}
#if HAVE_GETPID && 0 /* Disable this as pax attribute name. */
sprintf(buff, "GNUSparseFile.%d", getpid());
#else
/* If the platform can't fetch the pid, don't include it. */
strcpy(buff, "GNUSparseFile");
#endif
/* General case: build a ustar-compatible name adding
* "/GNUSparseFile/". */
build_ustar_entry_name(dest, src, p - src, buff);
build_ustar_entry_name(dest, src, p - src, "GNUSparseFile.0");
return (dest);
}

View File

@ -28,6 +28,7 @@
.Dt LIBARCHIVE_CHANGES 3
.Os
.Sh NAME
.Nm libarchive_changes
.Nd changes in libarchive interface
.\"
.Sh CHANGES IN LIBARCHIVE 3

View File

@ -183,7 +183,7 @@ test_read_format_mtree1(void)
min_time = archive_entry_mtime(ae);
assert(min_time <= 0);
/* Simply asserting min_time - 1 > 0 breaks with some compiler optimizations. */
t = min_time - 1;
t = (time_t)((uintmax_t)min_time - 1);
assert(t > 0);
assertEqualInt(archive_entry_is_encrypted(ae), 0);
assertEqualIntA(a, archive_read_has_encrypted_entries(a), ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED);

View File

@ -0,0 +1,60 @@
/*-
* Copyright (c) 2017 Phillip Berndt
* 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$");
/*
* Issue 869: zip files without a valid EOCD header aren't loaded even if they
* have a valid ZIP64 version of said header.
*/
DEFINE_TEST(test_read_format_zip_with_invalid_traditional_eocd)
{
const char *refname = "test_read_format_zip_with_invalid_traditional_eocd.zip";
char *p;
size_t s;
struct archive *a;
struct archive_entry *ae;
extract_reference_file(refname);
p = slurpfile(&s, refname);
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip_seekable(a));
assertEqualIntA(a, ARCHIVE_OK, read_open_memory_seek(a, p, s, 1));
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString("test1.txt", archive_entry_pathname(ae));
assertEqualInt(0, archive_entry_size(ae));
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString("test2.txt", archive_entry_pathname(ae));
assertEqualInt(0, archive_entry_size(ae));
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
free(p);
}

View File

@ -0,0 +1,14 @@
begin 644 test_read_format_zip_without_eocd.zip
M4$L#!"T`"````-IT@DH`````__________\)`"``=&5S=#$N='AT`0`<````
M````````````````````````````````````````````````````````````
M`%!+`P0M``@```#:=()*`````/__________"0`@`'1E<W0R+G1X=`$`'```
M````````````````````6P``````````````````````````````````````
M``!02P$"+0,M``@```#:=()*`````/__________"0`@````__\`````I('_
M____=&5S=#$N='AT`0`<``````````````````````````````````````!0
M2P$"+0,M``@```#:=()*`````/__________"0`@````__\`````I('_____
M=&5S=#(N='AT`0`<``````````````````````!;``````````````!02P8&
M+``````````M`RT````````````"``````````(`````````K@````````"V
M`````````%!+!@<`````9`$````````!````4$L%!O__________________
$__\`````
`
end

View File

@ -80,13 +80,19 @@ DEFINE_TEST(test_write_format_pax)
/*
* "file3" is sparse file and has hole size of which is
* 1024000 bytes, and has 8 bytes data after the hole.
*
* Pad the filename to make it larger than the ustar limit.
* It should still read back correctly.
*/
assert((ae = archive_entry_new()) != NULL);
archive_entry_set_atime(ae, 2, 20);
archive_entry_set_birthtime(ae, 3, 30);
archive_entry_set_ctime(ae, 4, 40);
archive_entry_set_mtime(ae, 5, 50);
archive_entry_copy_pathname(ae, "file3");
archive_entry_copy_pathname(ae, "file3"
"_123456789_123456789_123456789_123456789_123456789"
"_123456789_123456789_123456789_123456789_123456789"
"_123456789_123456789_123456789_123456789_123456789");
archive_entry_set_mode(ae, S_IFREG | 0755);
archive_entry_set_size(ae, 1024008);
archive_entry_sparse_add_entry(ae, 1024000, 8);
@ -171,7 +177,11 @@ DEFINE_TEST(test_write_format_pax)
assertEqualInt(40, archive_entry_ctime_nsec(ae));
assertEqualInt(5, archive_entry_mtime(ae));
assertEqualInt(50, archive_entry_mtime_nsec(ae));
assertEqualString("file3", archive_entry_pathname(ae));
assertEqualString("file3"
"_123456789_123456789_123456789_123456789_123456789"
"_123456789_123456789_123456789_123456789_123456789"
"_123456789_123456789_123456789_123456789_123456789",
archive_entry_pathname(ae));
assert((S_IFREG | 0755) == archive_entry_mode(ae));
assertEqualInt(1024008, archive_entry_size(ae));
assertEqualInt(1, archive_entry_sparse_reset(ae));

View File

@ -108,8 +108,19 @@ static void verify_write_uncompressed(struct archive *a)
}
/* Quick and dirty: Read 2-byte and 4-byte integers from Zip file. */
static int i2(const char *p) { return ((p[0] & 0xff) | ((p[1] & 0xff) << 8)); }
static int i4(const char *p) { return (i2(p) | (i2(p + 2) << 16)); }
static unsigned int
i2(const void *p_)
{
const unsigned char *p = p_;
return (p[0] | (p[1] << 8));
}
static unsigned int
i4(const void *p_)
{
const unsigned char *p = p_;
return (i2(p) | (i2(p + 2) << 16));
}
static void verify_uncompressed_contents(const char *buff, size_t used)
{

View File

@ -67,21 +67,19 @@ static int64_t memory_read_skip(struct archive *, void *, int64_t request);
static ssize_t memory_read(struct archive *, void *, const void **buff);
static ssize_t memory_write(struct archive *, void *, const void *, size_t);
static int16_t le16(const void *_p) {
static uint16_t le16(const void *_p) {
const uint8_t *p = _p;
return (0xff & (int16_t)p[0]) | ((0xff & (int16_t)p[1]) << 8);
return p[0] | (p[1] << 8);
}
static int32_t le32(const void *_p) {
static uint32_t le32(const void *_p) {
const uint8_t *p = _p;
int32_t v = 0xffff & (int32_t)le16(_p);
return v + ((0xffff & (int32_t)le16(p + 2)) << 16);
return le16(p) | ((uint32_t)le16(p + 2) << 16);
}
static int64_t le64(const void *_p) {
static uint64_t le64(const void *_p) {
const uint8_t *p = _p;
int64_t v = 0xffffffff & (int64_t)le32(_p);
return v + ((0xffffffff & (int64_t)le32(p + 4)) << 32);
return le32(p) | ((uint64_t)le32(p + 4) << 32);
}
static ssize_t

View File

@ -141,13 +141,19 @@ typedef struct _U32_S { U32 v; } _PACKED U32_S;
# pragma pack(pop)
#endif
#define A32(x) (((const U32_S *)(x))->v)
/****************************************
** Compiler-specific Functions and Macros
*****************************************/
#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
#define GCC_VERSION ((__GNUC__-0) * 100 + (__GNUC_MINOR__ - 0))
#if GCC_VERSION >= 409
__attribute__((__no_sanitize_undefined__))
#endif
static inline U32 A32(const void * x)
{
return (((const U32_S *)(x))->v);
}
/* Note : although _rotl exists for minGW (GCC under windows), performance seems poor */
#if defined(_MSC_VER)

View File

@ -1102,6 +1102,7 @@ assertion_file_contains_lines_any_order(const char *file, int line,
failure_start(pathname, line, "Can't allocate memory");
failure_finish(NULL);
free(expected);
free(buff);
return (0);
}
for (i = 0; lines[i] != NULL; ++i) {
@ -1124,6 +1125,7 @@ assertion_file_contains_lines_any_order(const char *file, int line,
failure_start(pathname, line, "Can't allocate memory");
failure_finish(NULL);
free(expected);
free(buff);
return (0);
}
for (j = 0, p = buff; p < buff + buff_size;

View File

@ -325,10 +325,6 @@ ATF_TC_HEAD(raw, tc)
ATF_TC_BODY(raw, tc)
{
#ifdef __FreeBSD__
atf_tc_expect_fail("fails with: clnt_call: "
"RPC: Can't decode result -- PR # 211804");
#endif
rawtest(NULL);
}

View File

@ -0,0 +1,10 @@
monkey
banana
apple
fruit
monkey
banna
apple
fruit
apple
monkey

View File

@ -0,0 +1,9 @@
monkey
banana
apple
fruit
monkey
banna
--
apple
monkey

View File

@ -0,0 +1,9 @@
monkey
banana
apple
fruit
monkey
banna
apple
fruit
apple

View File

@ -0,0 +1,8 @@
apple
fruit
--
banna
apple
fruit
apple
monkey

View File

@ -93,6 +93,12 @@ word_regexps_body()
{
atf_check -o file:"$(atf_get_srcdir)/d_word_regexps.out" \
grep -w separated $(atf_get_srcdir)/d_input
# Begin FreeBSD
printf "xmatch pmatch\n" > test1
atf_check -o inline:"pmatch\n" grep -Eow "(match )?pmatch" test1
# End FreeBSD
}
atf_test_case begin_end
@ -165,6 +171,12 @@ context_body()
atf_check -o file:d_context_b.out grep -A3 tilt d_context_a.in
atf_check -o file:d_context_c.out grep -B4 Whig d_context_a.in
atf_check -o file:d_context_d.out grep -C1 pig d_context_a.in d_context_b.in
atf_check -o file:d_context_e.out \
grep -E -C1 '(banana|monkey)' d_context_e.in
atf_check -o file:d_context_f.out \
grep -Ev -B2 '(banana|monkey|fruit)' d_context_e.in
atf_check -o file:d_context_g.out \
grep -Ev -A1 '(banana|monkey|fruit)' d_context_e.in
}
atf_test_case file_exp
@ -363,7 +375,7 @@ egrep_empty_invalid_head()
}
egrep_empty_invalid_body()
{
atf_check -s exit:1 egrep '{' /dev/null
atf_check -e ignore -s not-exit:0 egrep '{' /dev/null
}
atf_test_case zerolen
@ -380,6 +392,32 @@ zerolen_body()
atf_check -o inline:"Eggs\nCheese\n" grep -v -e "^$" test1
}
atf_test_case wflag_emptypat
wflag_emptypat_head()
{
atf_set "descr" "Check for proper handling of -w with an empty pattern (PR 105221)"
}
wflag_emptypat_body()
{
grep_type
if [ $? -eq $GREP_TYPE_GNU_FREEBSD ]; then
atf_expect_fail "this test does not pass with GNU grep in base"
fi
printf "" > test1
printf "\n" > test2
printf "qaz" > test3
printf " qaz\n" > test4
atf_check -s exit:1 -o empty grep -w -e "" test1
atf_check -o file:test2 grep -w -e "" test2
atf_check -s exit:1 -o empty grep -w -e "" test3
atf_check -o file:test4 grep -w -e "" test4
}
atf_test_case fgrep_sanity
fgrep_sanity_head()
{
@ -439,6 +477,23 @@ grep_sanity_body()
atf_check -o inline:"M\n" grep -o -e "M\{1\}" test2
}
atf_test_case wv_combo_break
wv_combo_break_head()
{
atf_set "descr" "Check for incorrectly matching lines with both -w and -v flags (PR 218467)"
}
wv_combo_break_body()
{
printf "x xx\n" > test1
printf "xx x\n" > test2
atf_check -o file:test1 grep -w "x" test1
atf_check -o file:test2 grep -w "x" test2
atf_check -s exit:1 grep -v -w "x" test1
atf_check -s exit:1 grep -v -w "x" test2
}
# End FreeBSD
atf_init_test_cases()
@ -467,6 +522,8 @@ atf_init_test_cases()
atf_add_test_case escmap
atf_add_test_case egrep_empty_invalid
atf_add_test_case zerolen
atf_add_test_case wflag_emptypat
atf_add_test_case wv_combo_break
atf_add_test_case fgrep_sanity
atf_add_test_case egrep_sanity
atf_add_test_case grep_sanity

View File

@ -39,6 +39,15 @@ print_map_entry() {
_p="$2"
case "${_fstype}" in
"exfat")
if [ -f "/usr/local/sbin/mount.exfat" ]; then
echo "-mountprog=/usr/local/sbin/mount.exfat,fstype=${_fstype},nosuid :/dev/${_p}"
else
/usr/bin/logger -p info -t "special_media[$$]" \
"Cannot mount ${_fstype} formatted device /dev/${_p}: Install sysutils/fusefs-exfat first"
exit 1
fi
;;
"ntfs")
if [ -f "/usr/local/bin/ntfs-3g" ]; then
echo "-mountprog=/usr/local/bin/ntfs-3g,fstype=${_fstype},nosuid :/dev/${_p}"

View File

@ -56,7 +56,7 @@ ipfw_start()
#
if checkyesno firewall_logging; then
echo 'Firewall logging enabled.'
sysctl net.inet.ip.fw.verbose=1 >/dev/null
${SYSCTL} net.inet.ip.fw.verbose=1 >/dev/null
fi
if checkyesno firewall_logif; then
ifconfig ipfw0 create
@ -78,11 +78,11 @@ ipfw_poststart()
# Enable the firewall
#
if ! ${SYSCTL} net.inet.ip.fw.enable=1 1>/dev/null 2>&1; then
if ! ${SYSCTL} net.inet.ip.fw.enable=1 >/dev/null 2>&1; then
warn "failed to enable IPv4 firewall"
fi
if afexists inet6; then
if ! ${SYSCTL} net.inet6.ip6.fw.enable=1 1>/dev/null 2>&1
if ! ${SYSCTL} net.inet6.ip6.fw.enable=1 >/dev/null 2>&1
then
warn "failed to enable IPv6 firewall"
fi
@ -95,9 +95,9 @@ ipfw_stop()
# Disable the firewall
#
${SYSCTL} net.inet.ip.fw.enable=0
${SYSCTL} net.inet.ip.fw.enable=0 >/dev/null
if afexists inet6; then
${SYSCTL} net.inet6.ip6.fw.enable=0
${SYSCTL} net.inet6.ip6.fw.enable=0 >/dev/null
fi
# Stop firewall coscripts

View File

@ -281,7 +281,7 @@ static_inet6()
esac
ifconfig ${ipv6_default_interface} inet6 defaultif
sysctl net.inet6.ip6.use_defaultzone=1
${SYSCTL} net.inet6.ip6.use_defaultzone=1 > /dev/null
}
ropts_init()

View File

@ -338,7 +338,7 @@ int ferror_unlocked(FILE *);
int fileno_unlocked(FILE *);
#endif
#if __POSIX_VISIBLE >= 200112
#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500
int fseeko(FILE *, __off_t, int);
__off_t ftello(FILE *);
#endif

View File

@ -195,6 +195,7 @@ TESTS_SRCS= \
test_read_format_zip_traditional_encryption_data.c \
test_read_format_zip_winzip_aes.c \
test_read_format_zip_winzip_aes_large.c \
test_read_format_zip_with_invalid_traditional_eocd.c \
test_read_format_zip_zip64.c \
test_read_large.c \
test_read_pax_schily_xattr.c \
@ -541,6 +542,7 @@ ${PACKAGE}FILES+= test_read_format_zip_sfx.uu
${PACKAGE}FILES+= test_read_format_zip_symlink.zip.uu
${PACKAGE}FILES+= test_read_format_zip_traditional_encryption_data.zip.uu
${PACKAGE}FILES+= test_read_format_zip_ux.zip.uu
${PACKAGE}FILES+= test_read_format_zip_with_invalid_traditional_eocd.zip.uu
${PACKAGE}FILES+= test_read_format_zip_winzip_aes128.zip.uu
${PACKAGE}FILES+= test_read_format_zip_winzip_aes256.zip.uu
${PACKAGE}FILES+= test_read_format_zip_winzip_aes256_large.zip.uu

View File

@ -46,6 +46,7 @@
#include <bitstring.h>
#include <netgraph/ng_message.h>
#include <netgraph/bluetooth/include/ng_bluetooth.h>
#include <netgraph/bluetooth/include/ng_hci.h>
#include <netgraph/bluetooth/include/ng_l2cap.h>
#include <netgraph/bluetooth/include/ng_btsocket.h>

View File

@ -903,61 +903,74 @@ globextend(const Char *path, glob_t *pglob, struct glob_limit *limit,
}
/*
* pattern matching function for filenames. Each occurrence of the *
* pattern causes a recursion level.
* pattern matching function for filenames.
*/
static int
match(Char *name, Char *pat, Char *patend)
{
int ok, negate_range;
Char c, k;
Char c, k, *nextp, *nextn;
struct xlocale_collate *table =
(struct xlocale_collate*)__get_locale()->components[XLC_COLLATE];
while (pat < patend) {
c = *pat++;
switch (c & M_MASK) {
case M_ALL:
if (pat == patend)
return (1);
do
if (match(name, pat, patend))
return (1);
while (*name++ != EOS);
return (0);
case M_ONE:
if (*name++ == EOS)
return (0);
break;
case M_SET:
ok = 0;
if ((k = *name++) == EOS)
return (0);
if ((negate_range = ((*pat & M_MASK) == M_NOT)) != 0)
++pat;
while (((c = *pat++) & M_MASK) != M_END)
if ((*pat & M_MASK) == M_RNG) {
if (table->__collate_load_error ?
CHAR(c) <= CHAR(k) &&
CHAR(k) <= CHAR(pat[1]) :
__wcollate_range_cmp(CHAR(c),
CHAR(k)) <= 0 &&
__wcollate_range_cmp(CHAR(k),
CHAR(pat[1])) <= 0)
nextn = NULL;
nextp = NULL;
while (1) {
while (pat < patend) {
c = *pat++;
switch (c & M_MASK) {
case M_ALL:
if (pat == patend)
return (1);
if (*name == EOS)
return (0);
nextn = name + 1;
nextp = pat - 1;
break;
case M_ONE:
if (*name++ == EOS)
goto fail;
break;
case M_SET:
ok = 0;
if ((k = *name++) == EOS)
goto fail;
negate_range = ((*pat & M_MASK) == M_NOT);
if (negate_range != 0)
++pat;
while (((c = *pat++) & M_MASK) != M_END)
if ((*pat & M_MASK) == M_RNG) {
if (table->__collate_load_error ?
CHAR(c) <= CHAR(k) &&
CHAR(k) <= CHAR(pat[1]) :
__wcollate_range_cmp(CHAR(c),
CHAR(k)) <= 0 &&
__wcollate_range_cmp(CHAR(k),
CHAR(pat[1])) <= 0)
ok = 1;
pat += 2;
} else if (c == k)
ok = 1;
pat += 2;
} else if (c == k)
ok = 1;
if (ok == negate_range)
return (0);
break;
default:
if (*name++ != c)
return (0);
break;
if (ok == negate_range)
goto fail;
break;
default:
if (*name++ != c)
goto fail;
break;
}
}
if (*name == EOS)
return (1);
fail:
if (nextn == NULL)
break;
pat = nextp;
name = nextn;
}
return (*name == EOS);
return (0);
}
/* Free allocated data belonging to a glob_t structure. */

View File

@ -41,6 +41,7 @@
#include <fcntl.h>
#include <pthread.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
@ -77,36 +78,34 @@ struct sem_nameinfo {
static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_mutex_t sem_llock;
static LIST_HEAD(,sem_nameinfo) sem_list = LIST_HEAD_INITIALIZER(sem_list);
static LIST_HEAD(, sem_nameinfo) sem_list = LIST_HEAD_INITIALIZER(sem_list);
static void
sem_prefork()
sem_prefork(void)
{
_pthread_mutex_lock(&sem_llock);
}
static void
sem_postfork()
sem_postfork(void)
{
_pthread_mutex_unlock(&sem_llock);
}
static void
sem_child_postfork()
sem_child_postfork(void)
{
_pthread_mutex_unlock(&sem_llock);
}
static void
sem_module_init(void)
{
pthread_mutexattr_t ma;
_pthread_mutexattr_init(&ma);
_pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_RECURSIVE);
_pthread_mutex_init(&sem_llock, &ma);
_pthread_mutexattr_destroy(&ma);
_pthread_mutex_init(&sem_llock, NULL);
_pthread_atfork(sem_prefork, sem_postfork, sem_child_postfork);
}
@ -116,10 +115,8 @@ sem_check_validity(sem_t *sem)
if (sem->_magic == SEM_MAGIC)
return (0);
else {
errno = EINVAL;
return (-1);
}
errno = EINVAL;
return (-1);
}
int
@ -142,13 +139,16 @@ sem_t *
_sem_open(const char *name, int flags, ...)
{
char path[PATH_MAX];
struct stat sb;
va_list ap;
struct sem_nameinfo *ni = NULL;
sem_t *sem = NULL;
int fd = -1, mode, len, errsave;
int value = 0;
struct sem_nameinfo *ni;
sem_t *sem, tmp;
int errsave, fd, len, mode, value;
ni = NULL;
sem = NULL;
fd = -1;
value = 0;
if (name[0] != '/') {
errno = EINVAL;
@ -213,8 +213,6 @@ _sem_open(const char *name, int flags, ...)
goto error;
}
if (sb.st_size < sizeof(sem_t)) {
sem_t tmp;
tmp._magic = SEM_MAGIC;
tmp._kern._count = value;
tmp._kern._flags = USYNC_PROCESS_SHARED | SEM_NAMED;
@ -222,8 +220,8 @@ _sem_open(const char *name, int flags, ...)
goto error;
}
flock(fd, LOCK_UN);
sem = (sem_t *)mmap(NULL, sizeof(sem_t), PROT_READ|PROT_WRITE,
MAP_SHARED|MAP_NOSYNC, fd, 0);
sem = mmap(NULL, sizeof(sem_t), PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_NOSYNC, fd, 0);
if (sem == MAP_FAILED) {
sem = NULL;
if (errno == ENOMEM)
@ -259,6 +257,7 @@ int
_sem_close(sem_t *sem)
{
struct sem_nameinfo *ni;
bool last;
if (sem_check_validity(sem) != 0)
return (-1);
@ -273,22 +272,17 @@ _sem_close(sem_t *sem)
_pthread_mutex_lock(&sem_llock);
LIST_FOREACH(ni, &sem_list, next) {
if (sem == ni->sem) {
if (--ni->open_count > 0) {
_pthread_mutex_unlock(&sem_llock);
return (0);
last = --ni->open_count == 0;
if (last)
LIST_REMOVE(ni, next);
_pthread_mutex_unlock(&sem_llock);
if (last) {
munmap(sem, sizeof(*sem));
free(ni);
}
else
break;
return (0);
}
}
if (ni) {
LIST_REMOVE(ni, next);
_pthread_mutex_unlock(&sem_llock);
munmap(sem, sizeof(*sem));
free(ni);
return (0);
}
_pthread_mutex_unlock(&sem_llock);
errno = EINVAL;
return (-1);
@ -342,7 +336,8 @@ _sem_getvalue(sem_t * __restrict sem, int * __restrict sval)
static __inline int
usem_wake(struct _usem2 *sem)
{
return _umtx_op(sem, UMTX_OP_SEM2_WAKE, 0, NULL, NULL);
return (_umtx_op(sem, UMTX_OP_SEM2_WAKE, 0, NULL, NULL));
}
static __inline int
@ -436,6 +431,7 @@ int
_sem_timedwait(sem_t * __restrict sem,
const struct timespec * __restrict abstime)
{
return (_sem_clockwait_np(sem, CLOCK_REALTIME, TIMER_ABSTIME, abstime,
NULL));
};
@ -443,7 +439,8 @@ _sem_timedwait(sem_t * __restrict sem,
int
_sem_wait(sem_t *sem)
{
return _sem_timedwait(sem, NULL);
return (_sem_timedwait(sem, NULL));
}
/*

View File

@ -444,6 +444,8 @@ p_ere_exp(struct parse *p)
(void)REQUIRE(!MORE() || !isdigit((uch)PEEK()), REG_BADRPT);
/* FALLTHROUGH */
default:
if (p->error != 0)
return;
p->next--;
wc = WGETNEXT();
ordinary(p, wc);
@ -651,6 +653,8 @@ p_simp_re(struct parse *p,
(void)REQUIRE(starordinary, REG_BADRPT);
/* FALLTHROUGH */
default:
if (p->error != 0)
return(0); /* Definitely not $... */
p->next--;
wc = WGETNEXT();
ordinary(p, wc);

View File

@ -54,8 +54,10 @@ END(__sys_##name)
ENTRY(__sys_##name); \
WEAK_REFERENCE(__sys_##name, _##name); \
_SYSCALL(name); \
bnez t0, cerror; \
bnez t0, 1f; \
ret; \
1: la t1, cerror; \
jr t1; \
END(__sys_##name)
#define RSYSCALL(name) \
@ -63,6 +65,8 @@ ENTRY(__sys_##name); \
WEAK_REFERENCE(__sys_##name, name); \
WEAK_REFERENCE(__sys_##name, _##name); \
_SYSCALL(name); \
bnez t0, cerror; \
bnez t0, 1f; \
ret; \
1: la t1, cerror; \
jr t1; \
END(__sys_##name)

View File

@ -42,10 +42,12 @@ ENTRY(__sys_vfork)
mv a2, ra
_SYSCALL(vfork)
bnez t0, cerror
bnez t0, 1f
addi a1, a1, -1
and a0, a0, a1
mv ra, a2
ret
1: la t1, cerror
jr t1
END(__sys_vfork)

View File

@ -108,18 +108,19 @@ xprt_register(SVCXPRT *xprt)
rwlock_wrlock(&svc_fd_lock);
if (__svc_xports == NULL) {
__svc_xports = (SVCXPRT **)
mem_alloc(FD_SETSIZE * sizeof(SVCXPRT *));
mem_alloc((FD_SETSIZE + 1) * sizeof(SVCXPRT *));
if (__svc_xports == NULL) {
rwlock_unlock(&svc_fd_lock);
return;
}
memset(__svc_xports, '\0', FD_SETSIZE * sizeof(SVCXPRT *));
memset(__svc_xports, '\0', (FD_SETSIZE + 1) * sizeof(SVCXPRT *));
}
if (sock < FD_SETSIZE) {
__svc_xports[sock] = xprt;
FD_SET(sock, &svc_fdset);
svc_maxfd = max(svc_maxfd, sock);
}
} else if (sock == FD_SETSIZE)
__svc_xports[sock] = xprt;
rwlock_unlock(&svc_fd_lock);
}
@ -157,7 +158,8 @@ __xprt_do_unregister(SVCXPRT *xprt, bool_t dolock)
if (__svc_xports[svc_maxfd])
break;
}
}
} else if ((sock == FD_SETSIZE) && (__svc_xports[sock] == xprt))
__svc_xports[sock] = NULL;
if (dolock)
rwlock_unlock(&svc_fd_lock);
}

View File

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd October 20, 2015
.Dd May 3, 2017
.Dt CPUSET 2
.Os
.Sh NAME
@ -101,6 +101,8 @@ argument may have the following values:
.It Dv CPU_WHICH_JAIL Ta "id is jid (jail id)"
.It Dv CPU_WHICH_CPUSET Ta "id is a cpusetid_t (cpuset id)"
.It Dv CPU_WHICH_IRQ Ta "id is an irq number"
.It Dv CPU_WHICH_INTRHANDLER Ta "id is an irq number for an interrupt handler"
.It Dv CPU_WHICH_ITHREAD Ta "id is an irq number for an ithread"
.It Dv CPU_WHICH_DOMAIN Ta "id is a NUMA domain"
.El
.Pp

View File

@ -8,6 +8,7 @@ ATF_TESTS_C+= fmtmsg_test
ATF_TESTS_C+= fnmatch2_test
ATF_TESTS_C+= fpclassify2_test
ATF_TESTS_C+= ftw_test
ATF_TESTS_C+= glob2_test
ATF_TESTS_C+= popen_test
ATF_TESTS_C+= posix_spawn_test
ATF_TESTS_C+= wordexp_test

View File

@ -0,0 +1,114 @@
/*
* Copyright (c) 2017 Dell EMC Isilon
* 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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 <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <errno.h>
#include <fcntl.h>
#include <glob.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <atf-c.h>
/*
* Derived from Russ Cox' pathological case test program used for the
* https://research.swtch.com/glob article.
*/
ATF_TC_WITHOUT_HEAD(glob_pathological_test);
ATF_TC_BODY(glob_pathological_test, tc)
{
struct timespec t, t2;
glob_t g;
const char *longname = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
char pattern[1000], *p;
double dt;
unsigned i, j, k, mul;
int fd, rc;
fd = open(longname, O_CREAT | O_RDWR, 0666);
ATF_REQUIRE(fd >= 0);
/*
* Test up to 100 a* groups. Exponential implementations typically go
* bang at i=7 or 8.
*/
for (i = 0; i < 100; i++) {
/*
* Create a*...b pattern with i 'a*' groups.
*/
p = pattern;
for (k = 0; k < i; k++) {
*p++ = 'a';
*p++ = '*';
}
*p++ = 'b';
*p = '\0';
clock_gettime(CLOCK_REALTIME, &t);
for (j = 0; j < mul; j++) {
memset(&g, 0, sizeof g);
rc = glob(pattern, 0, 0, &g);
if (rc == GLOB_NOSPACE || rc == GLOB_ABORTED) {
ATF_REQUIRE_MSG(rc == GLOB_NOMATCH,
"an unexpected error occurred: "
"rc=%d errno=%d", rc, errno);
/* NORETURN */
}
ATF_CHECK_MSG(rc == GLOB_NOMATCH,
"A bogus match occurred: '%s' ~ '%s'", pattern,
g.gl_pathv[0]);
globfree(&g);
}
clock_gettime(CLOCK_REALTIME, &t2);
t2.tv_sec -= t.tv_sec;
t2.tv_nsec -= t.tv_nsec;
dt = t2.tv_sec + (double)t2.tv_nsec/1e9;
dt /= mul;
ATF_CHECK_MSG(dt < 1, "glob(3) took far too long: %d %.9f", i,
dt);
if (dt >= 0.0001)
mul = 1;
}
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, glob_pathological_test);
return (atf_no_error());
}

View File

@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd February 24, 2016
.Dd April 28, 2017
.Dt EDITLINE 3
.Os
.Sh NAME
@ -767,7 +767,7 @@ Return the previous element in the history.
Return the next element in the history.
.It Dv H_CURR
Return the current element in the history.
.It Dv H_SET
.It Dv H_SET , Fa "int position"
Set the cursor to point to the requested element.
.It Dv H_ADD , Fa "const char *str"
Append

View File

@ -47,8 +47,10 @@ __FBSDID("$FreeBSD$");
#include <sys/thr.h>
#include <sys/umtx.h>
#include <netinet/in.h>
#include <netinet/sctp.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <netinet/udplite.h>
#include <nfsserver/nfs.h>
#include <ufs/ufs/quota.h>
#include <vm/vm.h>
@ -750,10 +752,16 @@ sysdecode_sockopt_name(int level, int optname)
if (level == IPPROTO_IP)
/* XXX: UNIX domain socket options use a level of 0 also. */
return (lookup_value(sockoptip, optname));
if (level == IPPROTO_IPV6)
return (lookup_value(sockoptipv6, optname));
if (level == IPPROTO_SCTP)
return (lookup_value(sockoptsctp, optname));
if (level == IPPROTO_TCP)
return (lookup_value(sockopttcp, optname));
if (level == IPPROTO_UDP)
return (lookup_value(sockoptudp, optname));
if (level == IPPROTO_UDPLITE)
return (lookup_value(sockoptudplite, optname));
return (NULL);
}

View File

@ -130,8 +130,11 @@ gen_table "sockfamily" "AF_[[:alnum:]]+[[:space:]]+" "sys/
gen_table "sockipproto" "IPPROTO_[[:alnum:]]+[[:space:]]+" "netinet/in.h"
gen_table "sockopt" "SO_[A-Z]+[[:space:]]+0x[0-9]+" "sys/socket.h"
gen_table "sockoptip" "(IP_[[:alnum:]_]+|MCAST_[[:alnum:]_]+_GROUP)[[:space:]]+" "netinet/in.h" "IP_DEFAULT|IP_MIN|IP_MAX|IP_PORTRANGE"
gen_table "sockoptipv6" "IPV6_[[:alnum:]_]+[[:space:]]+[0-9]+" "netinet6/in6.h" "IPV6_ADDR_|IPV6_TAG_DIRECT|IPV6_OPTIONS|IPV6_RECVOPTS|IPV6_RECVRETOPTS|IPV6_RECVDSTADDR|IPV6_RETOPTS|IPV6_2292|IPV6_RECVRTHDRDSTOPTS|IPV6_REACHCONF|IPV6_PKTOPTIONS"
gen_table "sockoptsctp" "SCTP_[[:alnum:]_]+[[:space:]]+[0-9]+" "netinet/sctp.h"
gen_table "sockopttcp" "TCP_[[:alnum:]_]+[[:space:]]+[0-9]+" "netinet/tcp.h" "TCP_MIN|TCP_MAX[^S]|TCP_MSS|TCP_[[:alnum:]_]+_MAX"
gen_table "sockoptudp" "UDP_[[:alnum:]]+[[:space:]]+[0-9]+" "netinet/udp.h" "UDP_ENCAP_"
gen_table "sockoptudplite" "UDPLITE_[[:alnum:]_]+[[:space:]]+[0-9]+" "netinet/udplite.h"
gen_table "socktype" "SOCK_[A-Z]+[[:space:]]+[1-9]+[0-9]*" "sys/socket.h"
gen_table "thrcreateflags" "THR_[A-Z]+[[:space:]]+0x[0-9]+" "sys/thr.h"
gen_table "umtxop" "UMTX_OP_[[:alnum:]_]+[[:space:]]+[0-9]+" "sys/umtx.h"

View File

@ -81,8 +81,8 @@ table.
.It "c2 num unused tty control flags to leave terminal as"
.It "ce bool false use crt erase algorithm"
.It "ck bool false use crt kill algorithm"
.It "cl str" Ta Dv NULL Ta
.No "screen clear sequence"
.It "cl str" Ta Dv NULL
.Ta No "screen clear sequence"
.It "co bool false console - add"
.Ql \en
after login prompt
@ -94,31 +94,31 @@ scripts
.It "dc num 0 chat debug bitmask"
.It "de num 0 delay secs and flush input before writing first prompt"
.It "df str %+ the" Xr strftime 3 "format used for \&%d in the banner message"
.It "ds str" Ta So Li ^Y Sc Ta
.No "delayed suspend character"
.It "ds str" Ta So Li ^Y
.Sc Ta No "delayed suspend character"
.It "dx bool false set"
.Dv DECCTLQ
.It "ec bool false leave echo"
.Em OFF
.It "ep bool false terminal uses even parity"
.It "er str" Ta So Li ^? Sc Ta
.No "erase character"
.It "et str" Ta So Li ^D Sc Ta
.No "end of text"
.It "er str" Ta So Li ^?
.Sc Ta No "erase character"
.It "et str" Ta So Li ^D
.Sc Ta No "end of text"
.Pq Dv EOF
character
.It "ev str" Ta Dv NULL Ta
.No "initial environment"
.It "ev str" Ta Dv NULL
.Ta No "initial environment"
.It "f0 num unused tty mode flags to write messages"
.It "f1 num unused tty mode flags to read login name"
.It "f2 num unused tty mode flags to leave terminal as"
.It "fl str" Ta So Li ^O Sc Ta
.No "output flush character"
.It "fl str" Ta So Li ^O
.Sc Ta No "output flush character"
.It "hc bool false do"
.Em NOT
hangup line on last close
.It "he str" Ta Dv NULL Ta
.No "hostname editing regular expression"
.It "he str" Ta Dv NULL
.Ta No "hostname editing regular expression"
.It "hn str hostname hostname"
.It "ht bool false terminal has real tabs"
.It "hw bool false do cts/rts hardware flow control"
@ -128,21 +128,21 @@ hangup line on last close
.It "ic str unused expect-send chat script for modem initialization"
.It "if str unused display named file before prompt, like /etc/issue"
.It "ig bool false ignore garbage characters in login name"
.It "im str" Ta Dv NULL Ta
.No "initial (banner) message"
.It "in str" Ta So Li ^C Sc Ta
.No "interrupt character"
.It "im str" Ta Dv NULL
.Ta No "initial (banner) message"
.It "in str" Ta So Li ^C
.Sc Ta No "interrupt character"
.It "is num unused input speed"
.It "kl str" Ta So Li ^U Sc Ta
.No "kill character"
.It "kl str" Ta So Li ^U
.Sc Ta No "kill character"
.It "l0 num unused tty local flags to write messages"
.It "l1 num unused tty local flags to read login name"
.It "l2 num unused tty local flags to leave terminal as"
.It "lm str login: login prompt"
.It "ln str" Ta So Li ^V Sc Ta
.No "``literal next'' character"
.It "lo str" Ta Pa /usr/bin/login Ta
.No "program to exec when name obtained"
.It "ln str" Ta So Li ^V
.Sc Ta No "``literal next'' character"
.It "lo str" Ta Pa /usr/bin/login
.Ta No "program to exec when name obtained"
.It "mb bool false do flow control based on carrier"
.It "nc bool false terminal does not supply carrier (set clocal)"
.It "nl bool false terminal has (or might have) a newline character"
@ -153,8 +153,8 @@ hangup line on last close
.It "o2 num unused tty output flags to leave terminal as"
.It "op bool false terminal uses odd parity"
.It "os num unused output speed"
.It "pc str" Ta So Li \e0 Sc Ta
.No "pad character"
.It "pc str" Ta So Li \e0
.Sc Ta No "pad character"
.It "pe bool false use printer (hard copy) erase algorithm"
.It "pf num 0 delay"
between first prompt and following flush (seconds)
@ -165,25 +165,25 @@ is specified
.It "ps bool false line connected to a"
.Tn MICOM
port selector
.It "qu str" Ta So Li \&^\e Sc Ta
.No "quit character"
.It "rp str" Ta So Li ^R Sc Ta
.No "line retype character"
.It "qu str" Ta So Li \&^\e
.Sc Ta No "quit character"
.It "rp str" Ta So Li ^R
.Sc Ta No "line retype character"
.It "rt num unused ring timeout when using"
.Va \&ac
.It "rw bool false do"
.Em NOT
use raw for input, use cbreak
.It "sp num unused line speed (input and output)"
.It "su str" Ta So Li ^Z Sc Ta
.No "suspend character"
.It "su str" Ta So Li ^Z
.Sc Ta No "suspend character"
.It "tc str none table continuation"
.It "to num 0 timeout (seconds)"
.It "tt str" Ta Dv NULL Ta
.No "terminal type (for environment)"
.It "tt str" Ta Dv NULL
.Ta No "terminal type (for environment)"
.It "ub bool false do unbuffered output (of prompts etc)"
.It "we str" Ta So Li ^W Sc Ta
.No "word erase character"
.It "we str" Ta So Li ^W
.Sc Ta No "word erase character"
.It "xc bool false do"
.Em NOT
echo control chars as

View File

@ -905,27 +905,6 @@
<para>[&arch.i386;] DEC DEFEA EISA (&man.fpa.4; driver)</para>
</sect2>
<sect2 xml:id="atm">
<title>ATM Interfaces</title>
<para>[&arch.i386;] Midway-based ATM interfaces
(&man.en.4; driver)</para>
<para>[&arch.i386;, &arch.sparc64;] FORE Systems,
Inc. PCA-200E ATM PCI Adapters (hfa and &man.fatm.4;
drivers)</para>
<para>[&arch.i386;] IDT NICStAR 77201/211-based ATM
Adapters (&man.idt.4; driver)</para>
<para>[&arch.i386;, &arch.sparc64;] FORE Systems,
Inc. HE155 and HE622 ATM interfaces (&man.hatm.4;
driver)</para>
<para>[&arch.i386;] IDT77252-based ATM cards
(&man.patm.4; driver)</para>
</sect2>
<sect2 xml:id="wlan">
<title>Wireless Network Interfaces</title>

View File

@ -156,7 +156,6 @@ CRUNCH_PROGS_sbin+= bsdlabel fdisk
CRUNCH_ALIAS_bsdlabel= disklabel
.endif
CRUNCH_SRCDIR_ilmid= ${SRCTOP}/sbin/atm/ilmid
CRUNCH_SRCDIR_rtquery= ${SRCTOP}/sbin/routed/rtquery
CRUNCH_SRCDIR_ipf= ${SRCTOP}/sbin/ipf/ipf
.if ${MK_ZFS} != "no"

View File

@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd February 17, 2017
.Dd May 3, 2017
.Dt CAMCONTROL 8
.Os
.Sh NAME
@ -102,10 +102,10 @@
.Op device id
.Nm
.Ic rescan
.Aq all | bus Ns Op :target:lun
.Aq all | device id | bus Ns Op :target:lun
.Nm
.Ic reset
.Aq all | bus Ns Op :target:lun
.Aq all | device id | bus Ns Op :target:lun
.Nm
.Ic defects
.Op device id
@ -578,12 +578,20 @@ start bit cleared and the load/eject bit set.
.It Ic rescan
Tell the kernel to scan all buses in the system (with the
.Ar all
argument), the given bus (XPT_SCAN_BUS), or bus:target:lun
argument), the given bus (XPT_SCAN_BUS), bus:target:lun or device
(XPT_SCAN_LUN) for new devices or devices that have gone away.
The user
may specify a scan of all buses, a single bus, or a lun.
Scanning all luns
on a target is not supported.
.Pp
If a device is specified by peripheral name and unit number, for instance
da4, it may only be rescanned if that device currently exists in the CAM EDT
(Existing Device Table).
If the device is no longer there (see
.Nm
devlist ),
you must use the bus:target:lun form to rescan it.
.It Ic reprobe
Tell the kernel to refresh the information about the device and
notify the upper layer,
@ -593,8 +601,8 @@ the disk size visible to the rest of the system.
.It Ic reset
Tell the kernel to reset all buses in the system (with the
.Ar all
argument) or the given bus (XPT_RESET_BUS) by issuing a SCSI bus
reset for that bus, or to reset the given bus:target:lun
argument), the given bus (XPT_RESET_BUS) by issuing a SCSI bus
reset for that bus, or to reset the given bus:target:lun or device
(XPT_RESET_DEV), typically by issuing a BUS DEVICE RESET message after
connecting to that device.
Note that this can have a destructive impact
@ -2488,7 +2496,7 @@ Specify the strptime format string, as documented in strptime(3).
The time must also be specified with the
.Fl T
option.
.It Fl T
.It Fl T Ar time
Provide the time in the format specified with the
.Fl f
option.
@ -2814,8 +2822,8 @@ drive
.Pa ada0 .
.Pp
.Bd -literal -offset indent
camcontrol timestamp sa0 -s -f "%A %c" \e
-T "Wednesday Wed Oct 26 21:43:57 2016"
camcontrol timestamp sa0 -s -f "%a, %d %b %Y %T %z" \e
-T "Wed, 26 Oct 2016 21:43:57 -0600"
.Ed
.Pp
Set the timestamp of drive

View File

@ -3131,12 +3131,107 @@ dorescan_or_reset(int argc, char **argv, int rescan)
tstr++;
if (strncasecmp(tstr, "all", strlen("all")) == 0)
arglist |= CAM_ARG_BUS;
else {
else if (isdigit(*tstr)) {
rv = parse_btl(argv[optind], &bus, &target, &lun, &arglist);
if (rv != 1 && rv != 3) {
warnx(must, rescan? "rescan" : "reset");
return(1);
}
} else {
char name[30];
int unit;
int fd = -1;
union ccb ccb;
/*
* Note that resetting or rescanning a device used to
* require a bus or bus:target:lun. This is because the
* device in question may not exist and you're trying to
* get the controller to rescan to find it. It may also be
* because the device is hung / unresponsive, and opening
* an unresponsive device is not desireable.
*
* It can be more convenient to reference a device by
* peripheral name and unit number, though, and it is
* possible to get the bus:target:lun for devices that
* currently exist in the EDT. So this can work for
* devices that we want to reset, or devices that exist
* that we want to rescan, but not devices that do not
* exist yet.
*
* So, we are careful here to look up the bus/target/lun
* for the device the user wants to operate on, specified
* by peripheral instance (e.g. da0, pass32) without
* actually opening that device. The process is similar to
* what cam_lookup_pass() does, except that we don't
* actually open the passthrough driver instance in the end.
*/
if (cam_get_device(tstr, name, sizeof(name), &unit) == -1) {
warnx("%s", cam_errbuf);
error = 1;
goto bailout;
}
if ((fd = open(XPT_DEVICE, O_RDWR)) == -1) {
warn("Unable to open %s", XPT_DEVICE);
error = 1;
goto bailout;
}
bzero(&ccb, sizeof(ccb));
/*
* The function code isn't strictly necessary for the
* GETPASSTHRU ioctl.
*/
ccb.ccb_h.func_code = XPT_GDEVLIST;
/*
* These two are necessary for the GETPASSTHRU ioctl to
* work.
*/
strlcpy(ccb.cgdl.periph_name, name,
sizeof(ccb.cgdl.periph_name));
ccb.cgdl.unit_number = unit;
/*
* Attempt to get the passthrough device. This ioctl will
* fail if the device name is null, if the device doesn't
* exist, or if the passthrough driver isn't in the kernel.
*/
if (ioctl(fd, CAMGETPASSTHRU, &ccb) == -1) {
warn("Unable to find bus:target:lun for device %s%d",
name, unit);
error = 1;
close(fd);
goto bailout;
}
if ((ccb.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
const struct cam_status_entry *entry;
entry = cam_fetch_status_entry(ccb.ccb_h.status);
warnx("Unable to find bus:target_lun for device %s%d, "
"CAM status: %s (%#x)", name, unit,
entry ? entry->status_text : "Unknown",
ccb.ccb_h.status);
error = 1;
close(fd);
goto bailout;
}
/*
* The kernel fills in the bus/target/lun. We don't
* need the passthrough device name and unit number since
* we aren't going to open it.
*/
bus = ccb.ccb_h.path_id;
target = ccb.ccb_h.target_id;
lun = ccb.ccb_h.target_lun;
arglist |= CAM_ARG_BUS | CAM_ARG_TARGET | CAM_ARG_LUN;
close(fd);
}
if ((arglist & CAM_ARG_BUS)
@ -3146,6 +3241,8 @@ dorescan_or_reset(int argc, char **argv, int rescan)
else
error = rescan_or_reset_bus(bus, rescan);
bailout:
return(error);
}
@ -8916,8 +9013,8 @@ usage(int printlong)
" camcontrol eject [dev_id][generic args]\n"
" camcontrol reprobe [dev_id][generic args]\n"
#endif /* MINIMALISTIC */
" camcontrol rescan <all | bus[:target:lun]>\n"
" camcontrol reset <all | bus[:target:lun]>\n"
" camcontrol rescan <all | bus[:target:lun] | dev_id>\n"
" camcontrol reset <all | bus[:target:lun] | dev_id>\n"
#ifndef MINIMALISTIC
" camcontrol defects [dev_id][generic args] <-f format> [-P][-G]\n"
" [-q][-s][-S offset][-X]\n"
@ -8996,8 +9093,8 @@ usage(int printlong)
"load send a Start Unit command to the device with the load bit set\n"
"eject send a Stop Unit command to the device with the eject bit set\n"
"reprobe update capacity information of the given device\n"
"rescan rescan all buses, the given bus, or bus:target:lun\n"
"reset reset all buses, the given bus, or bus:target:lun\n"
"rescan rescan all buses, the given bus, bus:target:lun or device\n"
"reset reset all buses, the given bus, bus:target:lun or device\n"
"defects read the defect list of the specified device\n"
"modepage display or edit (-e) the given mode page\n"
"cmd send the given SCSI command, may need -i or -o as well\n"

View File

@ -550,8 +550,7 @@ fw_validate_ibm(struct cam_device *dev, int retry_count, int timeout, int fd,
fprintf(stdout, "Firmware file is valid for this drive.\n");
retval = 0;
bailout:
if (ccb != NULL)
cam_freeccb(ccb);
cam_freeccb(ccb);
return (retval);
}
@ -753,8 +752,8 @@ fw_check_device_ready(struct cam_device *dev, camcontrol_devtype devtype,
goto bailout;
}
bailout:
if (ccb != NULL)
cam_freeccb(ccb);
free(ptr);
cam_freeccb(ccb);
return (retval);
}
@ -913,8 +912,7 @@ fw_download_img(struct cam_device *cam_dev, struct fw_vendor *vp,
bailout:
if (quiet == 0)
progress_complete(&progress, size - img_size);
if (ccb != NULL)
cam_freeccb(ccb);
cam_freeccb(ccb);
return (retval);
}
@ -923,6 +921,7 @@ fwdownload(struct cam_device *device, int argc, char **argv,
char *combinedopt, int printerrors, int task_attr, int retry_count,
int timeout)
{
union ccb *ccb = NULL;
struct fw_vendor *vp;
char *fw_img_path = NULL;
struct ata_params *ident_buf = NULL;
@ -965,8 +964,6 @@ fwdownload(struct cam_device *device, int argc, char **argv,
if ((devtype == CC_DT_ATA)
|| (devtype == CC_DT_ATA_BEHIND_SCSI)) {
union ccb *ccb;
ccb = cam_getccb(device);
if (ccb == NULL) {
warnx("couldn't allocate CCB");
@ -976,7 +973,6 @@ fwdownload(struct cam_device *device, int argc, char **argv,
if (ata_do_identify(device, retry_count, timeout, ccb,
&ident_buf) != 0) {
cam_freeccb(ccb);
retval = 1;
goto bailout;
}
@ -1048,6 +1044,7 @@ fwdownload(struct cam_device *device, int argc, char **argv,
fprintf(stdout, "Firmware download successful\n");
bailout:
cam_freeccb(ccb);
free(buf);
return (retval);
}

View File

@ -282,12 +282,18 @@ set_timestamp(struct cam_device *device, char *format_string,
ts = (uint64_t) time_value;
} else {
bzero(&time_struct, sizeof(struct tm));
strptime(timestamp_string, format_string, &time_struct);
if (strptime(timestamp_string, format_string,
&time_struct) == NULL) {
warnx("%s: strptime(3) failed", __func__);
error = 1;
goto bailout;
}
time_value = mktime(&time_struct);
ts = (uint64_t) time_value;
}
/* Convert time from seconds to milliseconds */
ts *= 1000;
bzero(&ts_p, sizeof(ts_p));
scsi_create_timestamp(ts_p.timestamp, ts);
scsi_set_timestamp(&ccb->csio,

View File

@ -73,6 +73,7 @@ volatile sig_atomic_t undo_restore;
static struct gclass *find_class(struct gmesh *, const char *);
static struct ggeom * find_geom(struct gclass *, const char *);
static int geom_is_withered(struct ggeom *);
static const char *find_geomcfg(struct ggeom *, const char *);
static const char *find_provcfg(struct gprovider *, const char *);
static struct gprovider *find_provider(struct ggeom *, off_t);
@ -215,7 +216,7 @@ find_geom(struct gclass *classp, const char *name)
LIST_FOREACH(gp, &classp->lg_geom, lg_geom) {
if (strcmp(gp->lg_name, name) != 0)
continue;
if (find_geomcfg(gp, "wither") == NULL)
if (!geom_is_withered(gp))
return (gp);
else
wgp = gp;
@ -223,6 +224,18 @@ find_geom(struct gclass *classp, const char *name)
return (wgp);
}
static int
geom_is_withered(struct ggeom *gp)
{
struct gconfig *gc;
LIST_FOREACH(gc, &gp->lg_config, lg_config) {
if (!strcmp(gc->lg_name, "wither"))
return (1);
}
return (0);
}
static const char *
find_geomcfg(struct ggeom *gp, const char *cfg)
{
@ -614,7 +627,7 @@ gpart_show_geom(struct ggeom *gp, const char *element, int show_providers)
off_t length, secsz;
int idx, wblocks, wname, wmax;
if (find_geomcfg(gp, "wither"))
if (geom_is_withered(gp))
return;
scheme = find_geomcfg(gp, "scheme");
if (scheme == NULL)

View File

@ -349,12 +349,14 @@ in6_getaddr(const char *s, int which)
bzero(&hints, sizeof(struct addrinfo));
hints.ai_family = AF_INET6;
error = getaddrinfo(s, NULL, &hints, &res);
if (error != 0) {
if (inet_pton(AF_INET6, s, &sin->sin6_addr) != 1)
errx(1, "%s: bad value", s);
} else {
bcopy(res->ai_addr, sin, res->ai_addrlen);
freeaddrinfo(res);
}
}
if (error != 0) {
if (inet_pton(AF_INET6, s, &sin->sin6_addr) != 1)
errx(1, "%s: bad value", s);
} else
bcopy(res->ai_addr, sin, res->ai_addrlen);
}
static int

View File

@ -57,8 +57,7 @@ static const char rcsid[] =
#define MAX_SYSCTL_TRY 5
#define ND6BITS "\020\001PERFORMNUD\002ACCEPT_RTADV\003PREFER_SOURCE" \
"\004IFDISABLED\005DONT_SET_IFROUTE\006AUTO_LINKLOCAL" \
"\007NO_RADR\010NO_PREFER_IFACE\011IGNORELOOP\012NO_DAD" \
"\020DEFAULTIF"
"\007NO_RADR\010NO_PREFER_IFACE\011NO_DAD\020DEFAULTIF"
static int isnd6defif(int);
void setnd6flags(const char *, int, int, const struct afswtch *);

View File

@ -87,6 +87,7 @@ list_cloners(void)
putchar('\n');
free(buf);
close(s);
}
struct clone_defcb {

View File

@ -28,7 +28,7 @@
.\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94
.\" $FreeBSD$
.\"
.Dd January 18, 2017
.Dd April 29, 2017
.Dt IFCONFIG 8
.Os
.Sh NAME
@ -2518,7 +2518,7 @@ means
Disable lacp strict compliance on the interface.
.El
.Pp
The following parameters are specific to IP tunnel interfaces,
The following parameters apply to IP tunnel interfaces,
.Xr gif 4 :
.Bl -tag -width indent
.It Cm tunnel Ar src_addr dest_addr
@ -2568,9 +2568,26 @@ Clear a flag
.Cm send_rev_ethip_ver .
.El
.Pp
The following parameters are specific to GRE tunnel interfaces,
The following parameters apply to GRE tunnel interfaces,
.Xr gre 4 :
.Bl -tag -width indent
.It Cm tunnel Ar src_addr dest_addr
Configure the physical source and destination address for GRE tunnel
interfaces.
The arguments
.Ar src_addr
and
.Ar dest_addr
are interpreted as the outer source/destination for the encapsulating
IPv4/IPv6 header.
.It Fl tunnel
Unconfigure the physical source and destination address for GRE tunnel
interfaces previously configured with
.Cm tunnel .
.It Cm deletetunnel
Another name for the
.Fl tunnel
parameter.
.It Cm grekey Ar key
Configure the GRE key to be used for outgoing packets.
Note that

View File

@ -106,7 +106,7 @@ static int ifconfig(int argc, char *const *argv, int iscreate,
static void status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
struct ifaddrs *ifa);
static void tunnel_status(int s);
static void usage(void);
static void usage(void) _Noreturn;
static struct afswtch *af_getbyname(const char *name);
static struct afswtch *af_getbyfamily(int af);
@ -802,26 +802,24 @@ ifconfig(int argc, char *const *argv, int iscreate, const struct afswtch *uafp)
*/
p = (setaddr ? &setifdstaddr_cmd : &setifaddr_cmd);
}
if (p->c_u.c_func || p->c_u.c_func2) {
if (p->c_parameter == NEXTARG) {
if (argv[1] == NULL)
errx(1, "'%s' requires argument",
p->c_name);
p->c_u.c_func(argv[1], 0, s, afp);
if (p->c_parameter == NEXTARG && p->c_u.c_func) {
if (argv[1] == NULL)
errx(1, "'%s' requires argument",
p->c_name);
p->c_u.c_func(argv[1], 0, s, afp);
argc--, argv++;
} else if (p->c_parameter == OPTARG && p->c_u.c_func) {
p->c_u.c_func(argv[1], 0, s, afp);
if (argv[1] != NULL)
argc--, argv++;
} else if (p->c_parameter == OPTARG) {
p->c_u.c_func(argv[1], 0, s, afp);
if (argv[1] != NULL)
argc--, argv++;
} else if (p->c_parameter == NEXTARG2) {
if (argc < 3)
errx(1, "'%s' requires 2 arguments",
p->c_name);
p->c_u.c_func2(argv[1], argv[2], s, afp);
argc -= 2, argv += 2;
} else
p->c_u.c_func(*argv, p->c_parameter, s, afp);
}
} else if (p->c_parameter == NEXTARG2 && p->c_u.c_func2) {
if (argc < 3)
errx(1, "'%s' requires 2 arguments",
p->c_name);
p->c_u.c_func2(argv[1], argv[2], s, afp);
argc -= 2, argv += 2;
} else if (p->c_u.c_func)
p->c_u.c_func(*argv, p->c_parameter, s, afp);
argc--, argv++;
}
@ -1297,8 +1295,8 @@ printb(const char *s, unsigned v, const char *bits)
printf("%s=%o", s, v);
else
printf("%s=%x", s, v);
bits++;
if (bits) {
bits++;
putchar('<');
while ((i = *bits++) != '\0') {
if (v & (1 << (i-1))) {
@ -1376,8 +1374,11 @@ ifmaybeload(const char *name)
}
}
/* not present, we should try to load it */
kldload(ifkind);
/*
* Try to load the module. But ignore failures, because ifconfig can't
* infer the names of all drivers (eg mlx4en(4)).
*/
(void) kldload(ifkind);
}
static struct cmd basic_cmds[] = {

View File

@ -200,24 +200,17 @@ static void
lagg_status(int s)
{
struct lagg_protos lpr[] = LAGG_PROTOS;
struct lagg_reqport rp, rpbuf[LAGG_MAX_PORTS];
struct lagg_reqport rpbuf[LAGG_MAX_PORTS];
struct lagg_reqall ra;
struct lagg_reqopts ro;
struct lagg_reqflags rf;
struct lacp_opreq *lp;
const char *proto = "<unknown>";
int i, isport = 0;
int i;
bzero(&rp, sizeof(rp));
bzero(&ra, sizeof(ra));
bzero(&ro, sizeof(ro));
strlcpy(rp.rp_ifname, name, sizeof(rp.rp_ifname));
strlcpy(rp.rp_portname, name, sizeof(rp.rp_portname));
if (ioctl(s, SIOCGLAGGPORT, &rp) == 0)
isport = 1;
strlcpy(ra.ra_ifname, name, sizeof(ra.ra_ifname));
ra.ra_size = sizeof(rpbuf);
ra.ra_port = rpbuf;
@ -257,8 +250,6 @@ lagg_status(int s)
sep = ",";
}
}
if (isport)
printf(" laggdev %s", rp.rp_ifname);
putchar('\n');
if (verbose) {
printf("\tlagg options:\n");

View File

@ -371,7 +371,7 @@ setmediamode(const char *val, int d, int s, const struct afswtch *afp)
}
/**********************************************************************
* A good chunk of this is duplicated from sys/net/ifmedia.c
* A good chunk of this is duplicated from sys/net/if_media.c
**********************************************************************/
static struct ifmedia_description ifm_type_descriptions[] =

View File

@ -120,6 +120,7 @@ setpfsync_syncpeer(const char *val, int d, int s, const struct afswtch *rafp)
if (ioctl(s, SIOCSETPFSYNC, (caddr_t)&ifr) == -1)
err(1, "SIOCSETPFSYNC");
freeaddrinfo(peerres);
}
/* ARGSUSED */

View File

@ -1881,7 +1881,7 @@ parse_range(int ac, char *av[], uint32_t *v, int len)
av--;
}
if (v[1] < v[0] ||
v[1] >= DN_MAX_ID-1 ||
v[0] >= DN_MAX_ID-1 ||
v[1] >= DN_MAX_ID-1) {
continue; /* invalid entry */
}

View File

@ -50,7 +50,9 @@ in-kernel NAT.
.Nm
.Oo Cm set Ar N Oc Cm table Ar name Cm create Ar create-options
.Nm
.Oo Cm set Ar N Oc Cm table Ar name Cm destroy
.Oo Cm set Ar N Oc Cm table
.Brq Ar name | all
.Cm destroy
.Nm
.Oo Cm set Ar N Oc Cm table Ar name Cm modify Ar modify-options
.Nm

View File

@ -3187,15 +3187,14 @@ fill_flags_cmd(ipfw_insn *cmd, enum ipfw_opcodes opcode,
void
ipfw_delete(char *av[])
{
ipfw_range_tlv rt;
char *sep;
int i, j;
int exitval = EX_OK;
int do_set = 0;
char *sep;
ipfw_range_tlv rt;
av++;
NEED1("missing rule specification");
memset(&rt, 0, sizeof(rt));
if ( *av && _substrcmp(*av, "set") == 0) {
/* Do not allow using the following syntax:
* ipfw set N delete set M
@ -3222,6 +3221,7 @@ ipfw_delete(char *av[])
} else if (co.do_pipe) {
exitval = ipfw_delete_pipe(co.do_pipe, i);
} else {
memset(&rt, 0, sizeof(rt));
if (do_set != 0) {
rt.set = i & 31;
rt.flags = IPFW_RCFLAG_SET;
@ -5157,18 +5157,17 @@ void
ipfw_zero(int ac, char *av[], int optname)
{
ipfw_range_tlv rt;
uint32_t arg;
int failed = EX_OK;
char const *errstr;
char const *name = optname ? "RESETLOG" : "ZERO";
uint32_t arg;
int failed = EX_OK;
optname = optname ? IP_FW_XRESETLOG : IP_FW_XZERO;
memset(&rt, 0, sizeof(rt));
av++; ac--;
if (ac == 0) {
/* clear all entries */
memset(&rt, 0, sizeof(rt));
rt.flags = IPFW_RCFLAG_ALL;
if (do_range_cmd(optname, &rt) < 0)
err(EX_UNAVAILABLE, "setsockopt(IP_FW_X%s)", name);
@ -5186,6 +5185,7 @@ ipfw_zero(int ac, char *av[], int optname)
if (errstr)
errx(EX_DATAERR,
"invalid rule number %s\n", *av);
memset(&rt, 0, sizeof(rt));
rt.start_rule = arg;
rt.end_rule = arg;
rt.flags |= IPFW_RCFLAG_RANGE;

View File

@ -54,6 +54,7 @@ static int table_swap(ipfw_obj_header *oh, char *second);
static int table_get_info(ipfw_obj_header *oh, ipfw_xtable_info *i);
static int table_show_info(ipfw_xtable_info *i, void *arg);
static int table_destroy_one(ipfw_xtable_info *i, void *arg);
static int table_flush_one(ipfw_xtable_info *i, void *arg);
static int table_show_one(ipfw_xtable_info *i, void *arg);
static int table_do_get_list(ipfw_xtable_info *i, ipfw_obj_header **poh);
@ -132,7 +133,7 @@ lookup_host (char *host, struct in_addr *ipaddr)
* This one handles all table-related commands
* ipfw table NAME create ...
* ipfw table NAME modify ...
* ipfw table NAME destroy
* ipfw table {NAME | all} destroy
* ipfw table NAME swap NAME
* ipfw table NAME lock
* ipfw table NAME unlock
@ -200,6 +201,7 @@ ipfw_table_handler(int ac, char *av[])
case TOK_INFO:
case TOK_DETAIL:
case TOK_FLUSH:
case TOK_DESTROY:
break;
default:
if (is_all != 0)
@ -223,13 +225,21 @@ ipfw_table_handler(int ac, char *av[])
table_modify(&oh, ac, av);
break;
case TOK_DESTROY:
if (table_destroy(&oh) == 0)
break;
if (errno != ESRCH)
err(EX_OSERR, "failed to destroy table %s", tablename);
/* ESRCH isn't fatal, warn if not quiet mode */
if (co.do_quiet == 0)
warn("failed to destroy table %s", tablename);
if (is_all == 0) {
if (table_destroy(&oh) == 0)
break;
if (errno != ESRCH)
err(EX_OSERR, "failed to destroy table %s",
tablename);
/* ESRCH isn't fatal, warn if not quiet mode */
if (co.do_quiet == 0)
warn("failed to destroy table %s", tablename);
} else {
error = tables_foreach(table_destroy_one, &oh, 1);
if (error != 0)
err(EX_OSERR,
"failed to destroy tables list");
}
break;
case TOK_FLUSH:
if (is_all == 0) {
@ -567,6 +577,22 @@ table_destroy(ipfw_obj_header *oh)
return (0);
}
static int
table_destroy_one(ipfw_xtable_info *i, void *arg)
{
ipfw_obj_header *oh;
oh = (ipfw_obj_header *)arg;
table_fill_ntlv(&oh->ntlv, i->tablename, i->set, 1);
if (table_destroy(oh) != 0) {
if (co.do_quiet == 0)
warn("failed to destroy table(%s) in set %u",
i->tablename, i->set);
return (-1);
}
return (0);
}
/*
* Flushes given table specified by @oh->ntlv.
* Returns 0 on success.
@ -1628,18 +1654,19 @@ tables_foreach(table_cb_t *f, void *arg, int sort)
}
if (sort != 0)
qsort(olh + 1, olh->count, olh->objsize, tablename_cmp);
qsort(olh + 1, olh->count, olh->objsize,
tablename_cmp);
info = (ipfw_xtable_info *)(olh + 1);
for (i = 0; i < olh->count; i++) {
error = f(info, arg); /* Ignore errors for now */
info = (ipfw_xtable_info *)((caddr_t)info + olh->objsize);
if (co.use_set == 0 || info->set == co.use_set - 1)
error = f(info, arg);
info = (ipfw_xtable_info *)((caddr_t)info +
olh->objsize);
}
free(olh);
break;
}
return (0);
}

View File

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd June 15, 2001
.Dd April 27, 2017
.Dt KLDCONFIG 8
.Os
.Sh NAME
@ -98,6 +98,7 @@ The default module search path used by the kernel.
.Sh SEE ALSO
.Xr kldload 2 ,
.Xr kldload 8 ,
.Xr kldxref 8 ,
.Xr sysctl 8
.Sh HISTORY
The

View File

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd March 18, 2012
.Dd April 27, 2017
.Dt KLDLOAD 8
.Os
.Sh NAME
@ -116,7 +116,8 @@ Modules may also be auto-loaded through their addition to
.Xr security 7 ,
.Xr kldconfig 8 ,
.Xr kldstat 8 ,
.Xr kldunload 8
.Xr kldunload 8 ,
.Xr kldxref 8
.Sh HISTORY
The
.Nm

View File

@ -118,6 +118,7 @@ MAN= aac.4 \
cxgb.4 \
cxgbe.4 \
cxgbev.4 \
cy.4 \
cyapa.4 \
da.4 \
dc.4 \

Some files were not shown because too many files have changed in this diff Show More