commit 52b3268b78346abe7781c984018558f312aa59d8
parent 8aa306fddcdc0ce264e8c946c46c2faa84d243ea
Author: Andrew Zaborowski <andrew.zaborowski@intel.com>
Date: Tue, 15 Jan 2019 07:34:05 +0100
netdev: Allow NULL prefix in netdev_frame_watch_add
Make sure we don't pass NULLs to memcmp or l_memdup when the prefix
buffer is NULL. There's no point having callers pass dummy buffers if
they need to watch frames independent of the frame data.
Diffstat:
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/netdev.c b/src/netdev.c
@@ -3676,7 +3676,8 @@ static bool netdev_frame_watch_match_prefix(const void *a, const void *b)
return fw->frame_type == info->frame_type &&
fw->prefix_len <= info->body_len &&
- !memcmp(fw->prefix, info->body, fw->prefix_len);
+ (fw->prefix_len == 0 ||
+ !memcmp(fw->prefix, info->body, fw->prefix_len));
}
static void netdev_mgmt_frame_event(struct l_genl_msg *msg,
@@ -4594,7 +4595,7 @@ uint32_t netdev_frame_watch_add(struct netdev *netdev, uint16_t frame_type,
fw = l_new(struct netdev_frame_watch, 1);
fw->frame_type = frame_type;
- fw->prefix = l_memdup(prefix, prefix_len);
+ fw->prefix = prefix_len ? l_memdup(prefix, prefix_len) : NULL;
fw->prefix_len = prefix_len;
id = watchlist_link(&netdev->frame_watches, &fw->super,
handler, user_data, NULL);