summaryrefslogtreecommitdiffstats
path: root/libxtables/xtables.c
diff options
context:
space:
mode:
Diffstat (limited to 'libxtables/xtables.c')
-rw-r--r--libxtables/xtables.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/libxtables/xtables.c b/libxtables/xtables.c
index 1ab86d5a..68411248 100644
--- a/libxtables/xtables.c
+++ b/libxtables/xtables.c
@@ -348,6 +348,11 @@ int xtables_insmod(const char *modname, const char *modprobe, bool quiet)
modprobe = buf;
}
+ argv[0] = (char *)modprobe;
+ argv[1] = (char *)modname;
+ argv[2] = quiet ? "-q" : NULL;
+ argv[3] = NULL;
+
/*
* Need to flush the buffer, or the child may output it again
* when switching the program thru execv.
@@ -356,19 +361,10 @@ int xtables_insmod(const char *modname, const char *modprobe, bool quiet)
switch (vfork()) {
case 0:
- argv[0] = (char *)modprobe;
- argv[1] = (char *)modname;
- if (quiet) {
- argv[2] = "-q";
- argv[3] = NULL;
- } else {
- argv[2] = NULL;
- argv[3] = NULL;
- }
execv(argv[0], argv);
/* not usually reached */
- exit(1);
+ _exit(1);
case -1:
free(buf);
return -1;
@@ -1702,8 +1698,9 @@ static struct in6_addr *parse_ip6mask(char *mask)
if (bits != 0) {
char *p = (void *)&maskaddr;
memset(p, 0xff, bits / 8);
- memset(p + (bits / 8) + 1, 0, (128 - bits) / 8);
- p[bits/8] = 0xff << (8 - (bits & 7));
+ memset(p + ((bits + 7) / 8), 0, (128 - bits) / 8);
+ if (bits < 128)
+ p[bits/8] = 0xff << (8 - (bits & 7));
return &maskaddr;
}