public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Jonathan Haws <jhaws@sdl.usu.edu>
Subject: Re: [B.A.T.M.A.N.] [PATCH v3] [alfred] IPv4 multicast distribution support.
Date: Thu, 19 Jan 2017 12:51:02 +0100	[thread overview]
Message-ID: <1572044.scLSiuJDnZ@bentobox> (raw)
In-Reply-To: <1484804915-14791-1-git-send-email-jhaws@sdl.usu.edu>

[-- Attachment #1: Type: text/plain, Size: 1421 bytes --]

Just had a quick look at the ARP cache code while going to lunch (rest was not 
checked):

> +int ipv4_to_mac(struct interface *interface,
> +		const alfred_addr *addr, struct ether_addr *mac)
> +{
> +	ipv4_arp_request(interface, addr, mac);
>  
>  	if (!is_valid_ether_addr(mac->ether_addr_octet))
>  		return -EINVAL;
[...]
> +
> +int ipv4_arp_request(struct interface *interface, const alfred_addr *addr,
> +		     struct ether_addr *mac)
> +{
> +	struct arpreq arpreq;
> +	struct sockaddr_in *sin;
> +
> +	memset(&arpreq, 0, sizeof(arpreq));
> +
> +	sin = (struct sockaddr_in *)&arpreq.arp_pa;
> +	sin->sin_family = AF_INET;
> +	sin->sin_addr.s_addr = addr->ipv4.s_addr;
> +
> +	strcpy(arpreq.arp_dev, interface->interface);
> +	if (ioctl(interface->netsock, SIOCGARP, &arpreq) < 0)
> +		return -1;
> +
> +	if (arpreq.arp_flags & ATF_COM) {
> +		memcpy(mac, arpreq.arp_ha.sa_data, sizeof(*mac));
> +	} else {
> +		perror("arp: incomplete");
> +		return -1;
> +	}
> +
> +	return 0;
> +}


This looks like you are not always initializing/setting the data for mac. And 
you are not checking the return value of ipv4_to_mac. So it is possible that 
your are accessing "random"/"uninitialized" data in is_valid_ether_addr. It 
can happen that your code accept bogus mac addresses (which are valid mac 
addresses but are not actually the mac address of the remote system) - which 
sounds wrong to me.

Kind regards,
	Sven


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      parent reply	other threads:[~2017-01-19 11:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-19  5:48 [B.A.T.M.A.N.] [PATCH v3] [alfred] IPv4 multicast distribution support Jonathan Haws
2017-01-19  5:51 ` Jonathan Haws
2017-01-19  7:53   ` Sven Eckelmann
2017-01-19  7:49 ` Sven Eckelmann
2017-01-19 11:51 ` Sven Eckelmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1572044.scLSiuJDnZ@bentobox \
    --to=sven@narfation.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=jhaws@sdl.usu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox