[2/2] alfred: Only accept valid mac addresses via unix socket
Commit Message
Not only 00:00:00:00:00:00 but also multicast addresses are invalid as data
source for alfred. These have to be checked too before accepting the mac
address received from the client over the unix socket.
Fixes: 58e109973bbe ("alfred: Allow setting the source mac via unix sock")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
unix_sock.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
Comments
On Friday 01 April 2016 19:22:36 Sven Eckelmann wrote:
> Not only 00:00:00:00:00:00 but also multicast addresses are invalid as data
> source for alfred. These have to be checked too before accepting the mac
> address received from the client over the unix socket.
>
> Fixes: 58e109973bbe ("alfred: Allow setting the source mac via unix sock")
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
Applied in revision 25b4ae6.
Thanks!
Simon
@@ -97,7 +97,6 @@ static int unix_sock_add_data(struct globals *globals,
struct alfred_push_data_v0 *push,
int client_sock)
{
- static const char zero[ETH_ALEN] = { 0 };
struct alfred_data *data;
struct dataset *dataset;
int len, data_len, ret = -1;
@@ -124,7 +123,7 @@ static int unix_sock_add_data(struct globals *globals,
/* clients should set the source mac to 00:00:00:00:00:00
* to make the server set the source for them
*/
- if (memcmp(zero, data->source, sizeof(data->source)) == 0)
+ if (!is_valid_ether_addr(data->source))
memcpy(data->source, &interface->hwaddr,
sizeof(interface->hwaddr));