summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-01-05 05:23:47 +0000
committerAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-01-05 05:23:47 +0000
commitbfd1c6f53c2ea423d1b3f84ff173ad077cf0b25b (patch)
treea9c55a16984ec6f34d690a44e0d408fdad7211f0 /sbin
parent29983c42f2f1c3b88530ec2d2114271c1cc3388d (diff)
Fix sending/receiving passwords (james@oaktree.co.uk)
Diffstat (limited to 'sbin')
-rw-r--r--sbin/routed/input.c12
-rw-r--r--sbin/routed/output.c23
2 files changed, 19 insertions, 16 deletions
diff --git a/sbin/routed/input.c b/sbin/routed/input.c
index 2aa8a4c766f..e03b88465d9 100644
--- a/sbin/routed/input.c
+++ b/sbin/routed/input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: input.c,v 1.9 1997/07/30 23:28:41 deraadt Exp $ */
+/* $OpenBSD: input.c,v 1.10 2001/01/05 05:23:46 angelos Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
@@ -36,7 +36,7 @@
#if !defined(lint)
static char sccsid[] = "@(#)input.c 8.1 (Berkeley) 6/5/93";
#else
-static char rcsid[] = "$OpenBSD: input.c,v 1.9 1997/07/30 23:28:41 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: input.c,v 1.10 2001/01/05 05:23:46 angelos Exp $";
#endif
#include "defs.h"
@@ -90,6 +90,7 @@ input(struct sockaddr_in *from, /* received from this IP address */
struct interface *aifp; /* interface if via 1 hop */
struct rt_entry *rt;
struct netinfo *n, *lim;
+ struct netauth *nap;
struct interface *ifp1;
naddr gate, mask, v1_mask, dst, ddst_h;
int i;
@@ -415,17 +416,16 @@ input(struct sockaddr_in *from, /* received from this IP address */
/* Authenticate the packet if we have a secret.
*/
if (aifp->int_passwd[0] != '\0') {
+ nap = (struct netauth *)(&n->n_tag);
if (n >= lim
|| n->n_family != RIP_AF_AUTH
- || ((struct netauth*)n)->a_type != RIP_AUTH_PW) {
+ || nap->a_type != RIP_AUTH_PW) {
if (from->sin_addr.s_addr != use_auth)
msglog("missing password from %s",
naddr_ntoa(FROM_NADDR));
use_auth = from->sin_addr.s_addr;
return;
-
- } else if (0 != bcmp(((struct netauth*)n)->au.au_pw,
- aifp->int_passwd,
+ } else if (0 != bcmp(nap->au.au_pw, aifp->int_passwd,
sizeof(aifp->int_passwd))) {
if (from->sin_addr.s_addr != use_auth)
msglog("bad password from %s",
diff --git a/sbin/routed/output.c b/sbin/routed/output.c
index 7c079a66f94..a19872cb17c 100644
--- a/sbin/routed/output.c
+++ b/sbin/routed/output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: output.c,v 1.5 1997/07/30 23:28:43 deraadt Exp $ */
+/* $OpenBSD: output.c,v 1.6 2001/01/05 05:23:46 angelos Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
@@ -36,7 +36,7 @@
#if !defined(lint)
static char sccsid[] = "@(#)output.c 8.1 (Berkeley) 6/5/93";
#else
-static char rcsid[] = "$OpenBSD: output.c,v 1.5 1997/07/30 23:28:43 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: output.c,v 1.6 2001/01/05 05:23:46 angelos Exp $";
#endif
#include "defs.h"
@@ -204,13 +204,16 @@ output(enum output_type type,
static void
set_auth(struct ws_buf *w)
{
+ struct netauth *nap;
+
if (ws.ifp != 0
&& ws.ifp->int_passwd[0] != '\0'
&& (ws.state & WS_ST_RIP2_SAFE)) {
+ nap = (struct netauth *)(&w->n->n_tag);
w->n->n_family = RIP_AF_AUTH;
- ((struct netauth*)w->n)->a_type = RIP_AUTH_PW;
- bcopy(ws.ifp->int_passwd, ((struct netauth*)w->n)->au.au_pw,
- sizeof(((struct netauth*)w->n)->au.au_pw));
+ nap->a_type = RIP_AUTH_PW;
+ bcopy(ws.ifp->int_passwd, nap->au.au_pw,
+ sizeof(nap->au.au_pw));
w->n++;
}
}
@@ -617,11 +620,6 @@ supply(struct sockaddr_in *dst,
}
ripv12_buf.rip.rip_vers = vers;
- ws.v12.n = ws.v12.base;
- set_auth(&ws.v12);
- ws.v2.n = ws.v2.base;
- set_auth(&ws.v2);
-
switch (type) {
case OUT_BROADCAST:
ws.v2.type = ((ws.ifp != 0
@@ -671,6 +669,11 @@ supply(struct sockaddr_in *dst,
ws.state |= WS_ST_SUB_AG;
}
+ ws.v12.n = ws.v12.base;
+ set_auth(&ws.v12);
+ ws.v2.n = ws.v2.base;
+ set_auth(&ws.v2);
+
if (supplier) {
/* Fake a default route if asked, and if there is not
* a better, real default route.