mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-14 04:59:59 +08:00
Update to FreeBSD head 2017-10-01
Git mirror commit b2f0376b45428f13151d229c5ae9d4d8f74acbd1. Update #3472.
This commit is contained in:
@@ -139,7 +139,7 @@ static const char xo_default_format[] = "%s";
|
||||
|
||||
#define XO_INDENT_BY 2 /* Amount to indent when pretty printing */
|
||||
#define XO_DEPTH 128 /* Default stack depth */
|
||||
#define XO_MAX_ANCHOR_WIDTH (8*1024) /* Anything wider is just sillyb */
|
||||
#define XO_MAX_ANCHOR_WIDTH (8*1024) /* Anything wider is just silly */
|
||||
|
||||
#define XO_FAILURE_NAME "failure"
|
||||
|
||||
@@ -5073,16 +5073,60 @@ xo_find_width (xo_handle_t *xop, xo_field_info_t *xfip,
|
||||
bp[vlen] = '\0';
|
||||
|
||||
width = strtol(bp, &cp, 0);
|
||||
if (width == LONG_MIN || width == LONG_MAX
|
||||
|| bp == cp || *cp != '\0' ) {
|
||||
if (width == LONG_MIN || width == LONG_MAX || bp == cp || *cp != '\0') {
|
||||
width = 0;
|
||||
xo_failure(xop, "invalid width for anchor: '%s'", bp);
|
||||
}
|
||||
} else if (flen) {
|
||||
if (flen != 2 || strncmp("%d", fmt, flen) != 0)
|
||||
xo_failure(xop, "invalid width format: '%*.*s'", flen, flen, fmt);
|
||||
if (!XOF_ISSET(xop, XOF_NO_VA_ARG))
|
||||
width = va_arg(xop->xo_vap, int);
|
||||
/*
|
||||
* We really expect the format for width to be "{:/%d}" or
|
||||
* "{:/%u}", so if that's the case, we just grab our width off
|
||||
* the argument list. But we need to avoid optimized logic if
|
||||
* there's a custom formatter.
|
||||
*/
|
||||
if (xop->xo_formatter == NULL && flen == 2
|
||||
&& strncmp("%d", fmt, flen) == 0) {
|
||||
if (!XOF_ISSET(xop, XOF_NO_VA_ARG))
|
||||
width = va_arg(xop->xo_vap, int);
|
||||
} else if (xop->xo_formatter == NULL && flen == 2
|
||||
&& strncmp("%u", fmt, flen) == 0) {
|
||||
if (!XOF_ISSET(xop, XOF_NO_VA_ARG))
|
||||
width = va_arg(xop->xo_vap, unsigned);
|
||||
} else {
|
||||
/*
|
||||
* So we have a format and it's not a simple one like
|
||||
* "{:/%d}". That means we need to format the field,
|
||||
* extract the value from the formatted output, and then
|
||||
* discard that output.
|
||||
*/
|
||||
int anchor_was_set = FALSE;
|
||||
xo_buffer_t *xbp = &xop->xo_data;
|
||||
ssize_t start_offset = xo_buf_offset(xbp);
|
||||
bp = xo_buf_cur(xbp); /* Save start of the string */
|
||||
cp = NULL;
|
||||
|
||||
if (XOIF_ISSET(xop, XOIF_ANCHOR)) {
|
||||
XOIF_CLEAR(xop, XOIF_ANCHOR);
|
||||
anchor_was_set = TRUE;
|
||||
}
|
||||
|
||||
ssize_t rc = xo_do_format_field(xop, xbp, fmt, flen, 0);
|
||||
if (rc >= 0) {
|
||||
xo_buf_append(xbp, "", 1); /* Append a NUL */
|
||||
|
||||
width = strtol(bp, &cp, 0);
|
||||
if (width == LONG_MIN || width == LONG_MAX
|
||||
|| bp == cp || *cp != '\0') {
|
||||
width = 0;
|
||||
xo_failure(xop, "invalid width for anchor: '%s'", bp);
|
||||
}
|
||||
}
|
||||
|
||||
/* Reset the cur pointer to where we found it */
|
||||
xbp->xb_curp = xbp->xb_bufp + start_offset;
|
||||
if (anchor_was_set)
|
||||
XOIF_SET(xop, XOIF_ANCHOR);
|
||||
}
|
||||
}
|
||||
|
||||
return width;
|
||||
@@ -5109,9 +5153,6 @@ static void
|
||||
xo_anchor_start (xo_handle_t *xop, xo_field_info_t *xfip,
|
||||
const char *value, ssize_t vlen)
|
||||
{
|
||||
if (xo_style(xop) != XO_STYLE_TEXT && xo_style(xop) != XO_STYLE_HTML)
|
||||
return;
|
||||
|
||||
if (XOIF_ISSET(xop, XOIF_ANCHOR))
|
||||
xo_failure(xop, "the anchor already recording is discarded");
|
||||
|
||||
@@ -5131,9 +5172,6 @@ static void
|
||||
xo_anchor_stop (xo_handle_t *xop, xo_field_info_t *xfip,
|
||||
const char *value, ssize_t vlen)
|
||||
{
|
||||
if (xo_style(xop) != XO_STYLE_TEXT && xo_style(xop) != XO_STYLE_HTML)
|
||||
return;
|
||||
|
||||
if (!XOIF_ISSET(xop, XOIF_ANCHOR)) {
|
||||
xo_failure(xop, "no start anchor");
|
||||
return;
|
||||
|
@@ -32,10 +32,10 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CASPER
|
||||
#ifdef WITH_CASPER
|
||||
#include <libcasper.h>
|
||||
#include <casper/cap_dns.h>
|
||||
#endif /* HAVE_CASPER */
|
||||
#endif /* WITH_CASPER */
|
||||
|
||||
#include <netdissect-stdinc.h>
|
||||
|
||||
@@ -208,7 +208,7 @@ intoa(uint32_t addr)
|
||||
|
||||
static uint32_t f_netmask;
|
||||
static uint32_t f_localnet;
|
||||
#ifdef HAVE_CASPER
|
||||
#ifdef WITH_CASPER
|
||||
extern cap_channel_t *capdns;
|
||||
#endif
|
||||
|
||||
@@ -256,7 +256,7 @@ getname(netdissect_options *ndo, const u_char *ap)
|
||||
*/
|
||||
if (!ndo->ndo_nflag &&
|
||||
(addr & f_netmask) == f_localnet) {
|
||||
#ifdef HAVE_CASPER
|
||||
#ifdef WITH_CASPER
|
||||
if (capdns != NULL) {
|
||||
hp = cap_gethostbyaddr(capdns, (char *)&addr, 4,
|
||||
AF_INET);
|
||||
@@ -317,7 +317,7 @@ getname6(netdissect_options *ndo, const u_char *ap)
|
||||
* Do not print names if -n was given.
|
||||
*/
|
||||
if (!ndo->ndo_nflag) {
|
||||
#ifdef HAVE_CASPER
|
||||
#ifdef WITH_CASPER
|
||||
if (capdns != NULL) {
|
||||
hp = cap_gethostbyaddr(capdns, (char *)&addr,
|
||||
sizeof(addr), AF_INET6);
|
||||
|
@@ -94,10 +94,10 @@ The Regents of the University of California. All rights reserved.\n";
|
||||
#include <sys/ioccom.h>
|
||||
#include <net/bpf.h>
|
||||
#include <libgen.h>
|
||||
#ifdef HAVE_CASPER
|
||||
#ifdef WITH_CASPER
|
||||
#include <libcasper.h>
|
||||
#include <casper/cap_dns.h>
|
||||
#endif /* HAVE_CASPER */
|
||||
#endif /* WITH_CASPER */
|
||||
#endif /* HAVE_CAPSICUM */
|
||||
#include <pcap.h>
|
||||
#include <signal.h>
|
||||
@@ -199,7 +199,7 @@ static int infoprint;
|
||||
|
||||
char *program_name;
|
||||
|
||||
#ifdef HAVE_CASPER
|
||||
#ifdef WITH_CASPER
|
||||
cap_channel_t *capdns;
|
||||
#endif
|
||||
|
||||
@@ -764,7 +764,7 @@ get_next_file(FILE *VFile, char *ptr)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef HAVE_CASPER
|
||||
#ifdef WITH_CASPER
|
||||
static cap_channel_t *
|
||||
capdns_setup(void)
|
||||
{
|
||||
@@ -791,7 +791,7 @@ capdns_setup(void)
|
||||
|
||||
return (capdnsloc);
|
||||
}
|
||||
#endif /* HAVE_CASPER */
|
||||
#endif /* WITH_CASPER */
|
||||
|
||||
#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
|
||||
static int
|
||||
@@ -1980,10 +1980,10 @@ main(int argc, char **argv)
|
||||
exit_tcpdump(0);
|
||||
}
|
||||
|
||||
#ifdef HAVE_CASPER
|
||||
#ifdef WITH_CASPER
|
||||
if (!ndo->ndo_nflag)
|
||||
capdns = capdns_setup();
|
||||
#endif /* HAVE_CASPER */
|
||||
#endif /* WITH_CASPER */
|
||||
|
||||
init_print(ndo, localnet, netmask, timezone_offset);
|
||||
|
||||
@@ -2207,11 +2207,11 @@ main(int argc, char **argv)
|
||||
|
||||
#ifdef HAVE_CAPSICUM
|
||||
cansandbox = (VFileName == NULL && zflag == NULL);
|
||||
#ifdef HAVE_CASPER
|
||||
#ifdef WITH_CASPER
|
||||
cansandbox = (cansandbox && (ndo->ndo_nflag || capdns != NULL));
|
||||
#else
|
||||
cansandbox = (cansandbox && ndo->ndo_nflag);
|
||||
#endif /* HAVE_CASPER */
|
||||
#endif /* WITH_CASPER */
|
||||
if (cansandbox && cap_enter() < 0 && errno != ENOSYS)
|
||||
error("unable to enter the capability mode");
|
||||
#endif /* HAVE_CAPSICUM */
|
||||
|
Reference in New Issue
Block a user