diff options
author | Ondrej Filip <feela@network.cz> | 2004-07-01 15:01:44 +0000 |
---|---|---|
committer | Ondrej Filip <feela@network.cz> | 2004-07-01 15:01:44 +0000 |
commit | 69b27ed6fd7794d36852764319e4dad19d4b6f87 (patch) | |
tree | bcf86c8287feb81acdc292a9ae8a1f5345a6e73e /proto/ospf/packet.c | |
parent | 02ad2737fd24573d870a5009a624c9b3c49aa176 (diff) |
Length calculation bugfix.
Diffstat (limited to 'proto/ospf/packet.c')
-rw-r--r-- | proto/ospf/packet.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/proto/ospf/packet.c b/proto/ospf/packet.c index 9334e595..b819c4a9 100644 --- a/proto/ospf/packet.c +++ b/proto/ospf/packet.c @@ -48,16 +48,17 @@ ospf_pkt_finalize(struct ospf_iface *ifa, struct ospf_packet *pkt) char password[OSPF_AUTH_CRYPT_SIZE]; pkt->autype = htons(ifa->autype); + bzero(pkt->u, sizeof(union ospf_auth)); switch(ifa->autype) { - case OSPF_AUTH_NONE: case OSPF_AUTH_SIMPLE: + password_cpy(pkt->u.password, passwd->password, 8); + case OSPF_AUTH_NONE: pkt->checksum = ipsum_calculate(pkt, sizeof(struct ospf_packet) - 8, (pkt + 1), ntohs(pkt->length) - sizeof(struct ospf_packet), NULL); - password_cpy(pkt->u.password, passwd->password, 8); break; case OSPF_AUTH_CRYPT: if (!passwd) @@ -89,10 +90,9 @@ ospf_pkt_finalize(struct ospf_iface *ifa, struct ospf_packet *pkt) } static int -ospf_pkt_checkauth(struct ospf_neighbor *n, struct ospf_packet *pkt, int size) +ospf_pkt_checkauth(struct ospf_neighbor *n, struct ospf_iface *ifa, struct ospf_packet *pkt, int size) { int i; - struct ospf_iface *ifa = n->ifa; struct proto_ospf *po = ifa->proto; struct proto *p = &po->proto; struct password_item *pass = NULL, *ptmp; @@ -108,6 +108,13 @@ ospf_pkt_checkauth(struct ospf_neighbor *n, struct ospf_packet *pkt, int size) return 0; } + if (n && (ifa != n->ifa)) + { + OSPF_TRACE(D_PACKETS, "OSPF_auth: received packet from strange interface (%s/%s)", + ifa->iface->name, n->ifa->iface->name); + return 0; + } + switch(ifa->autype) { case OSPF_AUTH_NONE: @@ -282,7 +289,7 @@ ospf_rx_hook(sock * sk, int size) return 1; } - if (!ospf_pkt_checkauth(n, ps, size)) + if (!ospf_pkt_checkauth(n, ifa, ps, size)) { log(L_ERR "%s%I - authentification failed", mesg, sk->faddr); return 1; @@ -371,7 +378,7 @@ void ospf_send_to(sock *sk, ip_addr ip, struct ospf_iface *ifa) { struct ospf_packet *pkt = (struct ospf_packet *) sk->tbuf; - int len = ntohs(pkt->length) + (pkt->autype == OSPF_AUTH_CRYPT) ? OSPF_AUTH_CRYPT_SIZE : 0; + int len = ntohs(pkt->length) + ((ifa->autype == OSPF_AUTH_CRYPT) ? OSPF_AUTH_CRYPT_SIZE : 0); ospf_pkt_finalize(ifa, pkt); if (ipa_equal(ip, IPA_NONE)) |