diff mbox

[2/2] alfred: Only accept valid mac addresses via unix socket

Message ID 1459531356-8361-2-git-send-email-sven@narfation.org
State Accepted, archived
Commit 25b4ae66dca453604e91d90d459b2523bb3da891
Delegated to: Simon Wunderlich
Headers show

Commit Message

Sven Eckelmann April 1, 2016, 5:22 p.m. UTC
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

Simon Wunderlich April 4, 2016, 3:48 p.m. UTC | #1
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
diff mbox

Patch

diff --git a/unix_sock.c b/unix_sock.c
index a0ccc13..ee6dd8f 100644
--- a/unix_sock.c
+++ b/unix_sock.c
@@ -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));