aboutsummaryrefslogtreecommitdiff
path: root/contrib/ipfilter/ipsend/sock.c
diff options
context:
space:
mode:
authorGuido van Rooij <guido@FreeBSD.org>2006-08-16 12:23:02 +0000
committerGuido van Rooij <guido@FreeBSD.org>2006-08-16 12:23:02 +0000
commitdac098f2c910f4e10b382c6c38aceee19d9dc719 (patch)
tree435ea094ad0e55736442383de5885c9c40c9d2a2 /contrib/ipfilter/ipsend/sock.c
parent4160f4c64e792b95d1d413f350b59eaf9fc1b6b9 (diff)
Notes
Diffstat (limited to 'contrib/ipfilter/ipsend/sock.c')
-rw-r--r--contrib/ipfilter/ipsend/sock.c45
1 files changed, 37 insertions, 8 deletions
diff --git a/contrib/ipfilter/ipsend/sock.c b/contrib/ipfilter/ipsend/sock.c
index 8c7bfcc5fd50..f6edbd2d148f 100644
--- a/contrib/ipfilter/ipsend/sock.c
+++ b/contrib/ipfilter/ipsend/sock.c
@@ -7,12 +7,20 @@
*/
#if !defined(lint)
static const char sccsid[] = "@(#)sock.c 1.2 1/11/96 (C)1995 Darren Reed";
-static const char rcsid[] = "@(#)$Id: sock.c,v 2.8.4.1 2004/03/23 12:58:06 darrenr Exp $";
+static const char rcsid[] = "@(#)$Id: sock.c,v 2.8.4.4 2006/03/21 16:10:56 darrenr Exp $";
#endif
#include <sys/param.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
+#if defined(__NetBSD__) && defined(__vax__)
+/*
+ * XXX need to declare boolean_t for _KERNEL <sys/files.h>
+ * which ends up including <sys/device.h> for vax. See PR#32907
+ * for further details.
+ */
+typedef int boolean_t;
+#endif
#ifndef ultrix
#include <fcntl.h>
#endif
@@ -302,28 +310,33 @@ struct tcpiphdr *ti;
}
#endif
+ o = NULL;
+ f = NULL;
+ s = NULL;
+ i = NULL;
+ t = NULL;
+
o = (struct file **)calloc(1, sizeof(*o) * (fd->fd_lastfile + 1));
if (KMCPY(o, fd->fd_ofiles, (fd->fd_lastfile + 1) * sizeof(*o)) == -1)
{
fprintf(stderr, "read(%#lx,%#lx,%lu) - u_ofile - failed\n",
(u_long)fd->fd_ofiles, (u_long)o, (u_long)sizeof(*o));
- return NULL;
+ goto finderror;
}
f = (struct file *)calloc(1, sizeof(*f));
if (KMCPY(f, o[tfd], sizeof(*f)) == -1)
{
fprintf(stderr, "read(%#lx,%#lx,%lu) - o[tfd] - failed\n",
(u_long)o[tfd], (u_long)f, (u_long)sizeof(*f));
- return NULL;
+ goto finderror;
}
s = (struct socket *)calloc(1, sizeof(*s));
if (KMCPY(s, f->f_data, sizeof(*s)) == -1)
{
fprintf(stderr, "read(%#lx,%#lx,%lu) - f_data - failed\n",
- (u_long)f->f_data, (u_long)s,
- (u_long)sizeof(*s));
- return NULL;
+ (u_long)f->f_data, (u_long)s, (u_long)sizeof(*s));
+ goto finderror;
}
i = (struct inpcb *)calloc(1, sizeof(*i));
@@ -331,7 +344,7 @@ struct tcpiphdr *ti;
{
fprintf(stderr, "kvm_read(%#lx,%#lx,%lu) - so_pcb - failed\n",
(u_long)s->so_pcb, (u_long)i, (u_long)sizeof(*i));
- return NULL;
+ goto finderror;
}
t = (struct tcpcb *)calloc(1, sizeof(*t));
@@ -339,9 +352,22 @@ struct tcpiphdr *ti;
{
fprintf(stderr, "read(%#lx,%#lx,%lu) - inp_ppcb - failed\n",
(u_long)i->inp_ppcb, (u_long)t, (u_long)sizeof(*t));
- return NULL;
+ goto finderror;
}
return (struct tcpcb *)i->inp_ppcb;
+
+finderror:
+ if (o != NULL)
+ free(o);
+ if (f != NULL)
+ free(f);
+ if (s != NULL)
+ free(s);
+ if (i != NULL)
+ free(i);
+ if (t != NULL)
+ free(t);
+ return NULL;
}
#endif /* BSD < 199301 */
@@ -383,7 +409,10 @@ struct in_addr gwip;
(void) getsockname(fd, (struct sockaddr *)&lsin, &len);
ti->ti_sport = lsin.sin_port;
printf("sport %d\n", ntohs(lsin.sin_port));
+
nfd = initdevice(dev, 1);
+ if (nfd == -1)
+ return -1;
if (!(t = find_tcp(fd, ti)))
return -1;