Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/ipf/dist From Darren Reed:
details: https://anonhg.NetBSD.org/src/rev/ad51dea8c904
branches: trunk
changeset: 329865:ad51dea8c904
user: christos <christos%NetBSD.org@localhost>
date: Thu Jun 12 17:23:06 2014 +0000
description:
>From Darren Reed:
This patch fixes "ipfstat" not displaying group rules and fixes problems
being able to remove individual rules using ipf/ipnat.
#547 rule parsing puts junk at the end of ipf rules
#546 ipfstat -io does not list rules in groups aside from 0
Due to unforeseen circumstances I'm not able to commit this myself.
diffstat:
external/bsd/ipf/dist/lib/gethost.c | 5 +++--
external/bsd/ipf/dist/tools/ipf_y.y | 10 ++++++++--
external/bsd/ipf/dist/tools/ipfstat.c | 31 +++----------------------------
external/bsd/ipf/dist/tools/ipnat_y.y | 6 ++++--
4 files changed, 18 insertions(+), 34 deletions(-)
diffs (133 lines):
diff -r 924ef2375cd9 -r ad51dea8c904 external/bsd/ipf/dist/lib/gethost.c
--- a/external/bsd/ipf/dist/lib/gethost.c Thu Jun 12 17:04:58 2014 +0000
+++ b/external/bsd/ipf/dist/lib/gethost.c Thu Jun 12 17:23:06 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gethost.c,v 1.2 2012/07/22 14:27:36 darrenr Exp $ */
+/* $NetBSD: gethost.c,v 1.3 2014/06/12 17:23:06 christos Exp $ */
/*
* Copyright (C) 2012 by Darren Reed.
@@ -19,6 +19,7 @@
struct netent *n;
u_32_t addr;
+ memset(hostp, sizeof(*hostp));
if (!strcmp(name, "test.host.dots")) {
if (family == AF_INET) {
hostp->in4.s_addr = htonl(0xfedcba98);
@@ -59,7 +60,7 @@
struct addrinfo hints, *res;
struct sockaddr_in6 *sin6;
- bzero((char *)&hints, sizeof(hints));
+ memset(&hints, sizeof(hints));
hints.ai_family = PF_INET6;
getaddrinfo(name, NULL, &hints, &res);
diff -r 924ef2375cd9 -r ad51dea8c904 external/bsd/ipf/dist/tools/ipf_y.y
--- a/external/bsd/ipf/dist/tools/ipf_y.y Thu Jun 12 17:04:58 2014 +0000
+++ b/external/bsd/ipf/dist/tools/ipf_y.y Thu Jun 12 17:23:06 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ipf_y.y,v 1.1.1.2 2012/07/22 13:44:52 darrenr Exp $ */
+/* $NetBSD: ipf_y.y,v 1.2 2014/06/12 17:23:06 christos Exp $ */
/*
* Copyright (C) 2012 by Darren Reed.
@@ -2601,7 +2601,13 @@
int pos;
nlen = strlen(name) + 1;
- f = realloc(*frp, (*frp)->fr_size + nlen);
+ /*
+ * realloc is harder to use here because the end of the structure
+ * needs to be zero'd, else it gets junk bytes.
+ */
+ f = calloc(1, (*frp)->fr_size + nlen);
+ memcpy(f, *frp, (*frp)->fr_size);
+ free(*frp);
if (*frp == frc)
frc = f;
*frp = f;
diff -r 924ef2375cd9 -r ad51dea8c904 external/bsd/ipf/dist/tools/ipfstat.c
--- a/external/bsd/ipf/dist/tools/ipfstat.c Thu Jun 12 17:04:58 2014 +0000
+++ b/external/bsd/ipf/dist/tools/ipfstat.c Thu Jun 12 17:23:06 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ipfstat.c,v 1.3 2012/07/22 14:27:51 darrenr Exp $ */
+/* $NetBSD: ipfstat.c,v 1.4 2014/06/12 17:23:06 christos Exp $ */
/*
* Copyright (C) 2012 by Darren Reed.
@@ -799,7 +799,6 @@
struct frentry fb;
ipfruleiter_t rule;
frentry_t zero;
- frgroup_t *g;
ipfobj_t obj;
void *buf;
size_t bufsiz;
@@ -833,7 +832,7 @@
if ((buf = malloc(bufsiz = sizeof(*fp) + 10240)) == NULL)
return 0;
- do {
+ while (rule.iri_rule != NULL) {
memset(buf, 0xff, bufsiz);
fp = buf;
rule.iri_rule = fp;
@@ -886,35 +885,11 @@
if (fp->fr_data != NULL && fp->fr_dsize > 0)
binprint(fp->fr_data, fp->fr_dsize);
}
- if (fp->fr_grhead != -1) {
- for (g = grtop; g != NULL; g = g->fg_next) {
- if (!strncmp(fp->fr_names + fp->fr_grhead,
- g->fg_name,
- FR_GROUPLEN))
- break;
- }
- if (g == NULL) {
- g = calloc(1, sizeof(*g));
-
- if (g != NULL) {
- strncpy(g->fg_name,
- fp->fr_names + fp->fr_grhead,
- FR_GROUPLEN);
- if (grtop == NULL) {
- grtop = g;
- grtail = g;
- } else {
- grtail->fg_next = g;
- grtail = g;
- }
- }
- }
- }
if (fp->fr_type == FR_T_CALLFUNC) {
rules += printlivelist(fiop, out, set, fp->fr_data,
group, "# callfunc: ");
}
- } while (fp->fr_next != NULL);
+ }
num = IPFGENITER_IPF;
(void) ioctl(ipf_fd,SIOCIPFDELTOK, &num);
diff -r 924ef2375cd9 -r ad51dea8c904 external/bsd/ipf/dist/tools/ipnat_y.y
--- a/external/bsd/ipf/dist/tools/ipnat_y.y Thu Jun 12 17:04:58 2014 +0000
+++ b/external/bsd/ipf/dist/tools/ipnat_y.y Thu Jun 12 17:23:06 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ipnat_y.y,v 1.1.1.2 2012/07/22 13:44:57 darrenr Exp $ */
+/* $NetBSD: ipnat_y.y,v 1.2 2014/06/12 17:23:06 christos Exp $ */
/*
* Copyright (C) 2012 by Darren Reed.
@@ -1762,7 +1762,9 @@
int pos;
nlen = strlen(name) + 1;
- n = realloc(*np, (*np)->in_size + nlen);
+ n = calloc(1, (*np)->in_size + nlen);
+ memcpy(n, *np (*np)->in_size);
+ free(*np);
if (*np == nattop)
nattop = n;
*np = n;
Home |
Main Index |
Thread Index |
Old Index