summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormmcc <mmcc@openbsd.org>2016-03-15 05:03:11 +0000
committermmcc <mmcc@openbsd.org>2016-03-15 05:03:11 +0000
commit4d3ec93064cf2a2dab669ce2e949c0bae369a120 (patch)
tree73a21fcef5c9d9b7c5020edfe48d6b586326a182
parentRemove now unused legacy uiomovei() function. (diff)
downloadwireguard-openbsd-4d3ec93064cf2a2dab669ce2e949c0bae369a120.tar.xz
wireguard-openbsd-4d3ec93064cf2a2dab669ce2e949c0bae369a120.zip
o remove legacy code that defines abs(3) if it isn't available
o inline an ugly and potentially risky macro of the form: #define x if (a) b; else o fix a >21 y.o. bug resulting from someone writing: puts("[nothing to parse], stdout"); when they meant: fputs("[nothing to parse]", stdout); ok canacar@
-rw-r--r--usr.sbin/tcpdump/print-icmp6.c6
-rw-r--r--usr.sbin/tcpdump/print-snmp.c40
2 files changed, 32 insertions, 14 deletions
diff --git a/usr.sbin/tcpdump/print-icmp6.c b/usr.sbin/tcpdump/print-icmp6.c
index 969324fab0d..a21c4010309 100644
--- a/usr.sbin/tcpdump/print-icmp6.c
+++ b/usr.sbin/tcpdump/print-icmp6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print-icmp6.c,v 1.17 2015/11/16 00:16:39 mmcc Exp $ */
+/* $OpenBSD: print-icmp6.c,v 1.18 2016/03/15 05:03:11 mmcc Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
@@ -43,6 +43,7 @@
#include <arpa/inet.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <netinet/ip6.h>
@@ -435,9 +436,6 @@ icmp6_print(const u_char *bp, u_int length, const u_char *bp2)
mode = FQDN;
}
}
-#ifndef abs
-#define abs(a) ((0 < (a)) ? (a) : -(a))
-#endif
if (mode == UNKNOWN && 2 < abs(buf[12] - (ep - buf - 13)))
mode = WRU;
if (mode == UNKNOWN)
diff --git a/usr.sbin/tcpdump/print-snmp.c b/usr.sbin/tcpdump/print-snmp.c
index 64a0f613c38..0ec491a12df 100644
--- a/usr.sbin/tcpdump/print-snmp.c
+++ b/usr.sbin/tcpdump/print-snmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print-snmp.c,v 1.20 2015/11/18 15:36:20 mmcc Exp $ */
+/* $OpenBSD: print-snmp.c,v 1.21 2016/03/15 05:03:11 mmcc Exp $ */
/*
* Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
@@ -346,7 +346,6 @@ struct be {
* it to decode.
*/
static int truncated;
-#define ifNotTruncated if (truncated) fputs("[|snmp]", stdout); else
/*
* This decodes the next ASN.1 object in the stream pointed to by "p"
@@ -365,7 +364,10 @@ asn1_parse(const u_char *p, u_int len, struct be *elem)
elem->asnlen = 0;
elem->type = BE_ANY;
if (len < 1) {
- ifNotTruncated puts("[nothing to parse], stdout");
+ if (truncated)
+ fputs("[|snmp]", stdout);
+ else
+ fputs("[nothing to parse]", stdout);
return -1;
}
@@ -399,7 +401,10 @@ asn1_parse(const u_char *p, u_int len, struct be *elem)
id = (id << 7) | (*p & ~ASN_BIT8);
}
if (len == 0 && *p & ASN_BIT8) {
- ifNotTruncated fputs("[Xtagfield?]", stdout);
+ if (truncated)
+ fputs("[|snmp]", stdout);
+ else
+ fputs("[Xtagfield?]", stdout);
return -1;
}
elem->id = id = (id << 7) | *p;
@@ -408,7 +413,10 @@ asn1_parse(const u_char *p, u_int len, struct be *elem)
++p;
}
if (len < 1) {
- ifNotTruncated fputs("[no asnlen]", stdout);
+ if (truncated)
+ fputs("[|snmp]", stdout);
+ else
+ fputs("[no asnlen]", stdout);
return -1;
}
elem->asnlen = *p;
@@ -419,7 +427,10 @@ asn1_parse(const u_char *p, u_int len, struct be *elem)
int noct = elem->asnlen % ASN_BIT8;
elem->asnlen = 0;
if (len < noct) {
- ifNotTruncated printf("[asnlen? %d<%d]", len, noct);
+ if (truncated)
+ fputs("[|snmp]", stdout);
+ else
+ printf("[asnlen? %d<%d]", len, noct);
return -1;
}
for (; noct-- > 0; len--, hdr++) {
@@ -437,16 +448,25 @@ asn1_parse(const u_char *p, u_int len, struct be *elem)
elem->asnlen = len;
}
if (form >= sizeof(Form)/sizeof(Form[0])) {
- ifNotTruncated printf("[form?%d]", form);
+ if (truncated)
+ fputs("[|snmp]", stdout);
+ else
+ printf("[form?%d]", form);
return -1;
}
if (class >= sizeof(Class)/sizeof(Class[0])) {
- ifNotTruncated printf("[class?%c/%d]", *Form[form], class);
+ if (truncated)
+ fputs("[|snmp]", stdout);
+ else
+ printf("[class?%c/%d]", *Form[form], class);
return -1;
}
if ((int)id >= Class[class].numIDs) {
- ifNotTruncated printf("[id?%c/%s/%d]", *Form[form],
- Class[class].name, id);
+ if (truncated)
+ fputs("[|snmp]", stdout);
+ else
+ printf("[id?%c/%s/%d]", *Form[form],
+ Class[class].name, id);
return -1;
}