Length calculation bugfix.
This commit is contained in:
parent
02ad2737fd
commit
69b27ed6fd
1 changed files with 13 additions and 6 deletions
|
@ -48,16 +48,17 @@ ospf_pkt_finalize(struct ospf_iface *ifa, struct ospf_packet *pkt)
|
||||||
char password[OSPF_AUTH_CRYPT_SIZE];
|
char password[OSPF_AUTH_CRYPT_SIZE];
|
||||||
|
|
||||||
pkt->autype = htons(ifa->autype);
|
pkt->autype = htons(ifa->autype);
|
||||||
|
bzero(pkt->u, sizeof(union ospf_auth));
|
||||||
|
|
||||||
switch(ifa->autype)
|
switch(ifa->autype)
|
||||||
{
|
{
|
||||||
case OSPF_AUTH_NONE:
|
|
||||||
case OSPF_AUTH_SIMPLE:
|
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->checksum = ipsum_calculate(pkt, sizeof(struct ospf_packet) - 8,
|
||||||
(pkt + 1),
|
(pkt + 1),
|
||||||
ntohs(pkt->length) -
|
ntohs(pkt->length) -
|
||||||
sizeof(struct ospf_packet), NULL);
|
sizeof(struct ospf_packet), NULL);
|
||||||
password_cpy(pkt->u.password, passwd->password, 8);
|
|
||||||
break;
|
break;
|
||||||
case OSPF_AUTH_CRYPT:
|
case OSPF_AUTH_CRYPT:
|
||||||
if (!passwd)
|
if (!passwd)
|
||||||
|
@ -89,10 +90,9 @@ ospf_pkt_finalize(struct ospf_iface *ifa, struct ospf_packet *pkt)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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;
|
int i;
|
||||||
struct ospf_iface *ifa = n->ifa;
|
|
||||||
struct proto_ospf *po = ifa->proto;
|
struct proto_ospf *po = ifa->proto;
|
||||||
struct proto *p = &po->proto;
|
struct proto *p = &po->proto;
|
||||||
struct password_item *pass = NULL, *ptmp;
|
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;
|
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)
|
switch(ifa->autype)
|
||||||
{
|
{
|
||||||
case OSPF_AUTH_NONE:
|
case OSPF_AUTH_NONE:
|
||||||
|
@ -282,7 +289,7 @@ ospf_rx_hook(sock * sk, int size)
|
||||||
return 1;
|
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);
|
log(L_ERR "%s%I - authentification failed", mesg, sk->faddr);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -371,7 +378,7 @@ void
|
||||||
ospf_send_to(sock *sk, ip_addr ip, struct ospf_iface *ifa)
|
ospf_send_to(sock *sk, ip_addr ip, struct ospf_iface *ifa)
|
||||||
{
|
{
|
||||||
struct ospf_packet *pkt = (struct ospf_packet *) sk->tbuf;
|
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);
|
ospf_pkt_finalize(ifa, pkt);
|
||||||
|
|
||||||
if (ipa_equal(ip, IPA_NONE))
|
if (ipa_equal(ip, IPA_NONE))
|
||||||
|
|
Loading…
Reference in a new issue