diff mbox series

[BlueZ,1/4] mesh: On node attach, verify element/model composition only

Message ID 20200509000024.5704-2-inga.stotland@intel.com (mailing list archive)
State Accepted
Headers show
Series Allow some composition fields update | expand

Commit Message

Stotland, Inga May 9, 2020, midnight UTC
When attaching an existing node, verify only the "elements" part
of device composition, i.e., skip verification of CID/PID/VID, CRPL
and features.
---
 mesh/node.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Comments

Brian Gix May 9, 2020, 1:49 p.m. UTC | #1
Applying this patch of the set early, due to popular demand.

On Fri, 2020-05-08 at 17:00 -0700, Inga Stotland wrote:
> When attaching an existing node, verify only the "elements" part
> of device composition, i.e., skip verification of CID/PID/VID, CRPL
> and features.
> ---
>  mesh/node.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/mesh/node.c b/mesh/node.c
> index acda6d472..e3f9e52e3 100644
> --- a/mesh/node.c
> +++ b/mesh/node.c
> @@ -1378,7 +1378,7 @@ static bool check_req_node(struct managed_obj_request *req)
>  {
>  	uint8_t node_comp[MAX_MSG_LEN - 2];
>  	uint8_t attach_comp[MAX_MSG_LEN - 2];
> -
> +	uint16_t offset = 10;
>  	uint16_t node_len = node_generate_comp(req->node, node_comp,
>  							sizeof(node_comp));
>  
> @@ -1389,12 +1389,10 @@ static bool check_req_node(struct managed_obj_request *req)
>  		uint16_t attach_len = node_generate_comp(req->attach,
>  					attach_comp, sizeof(attach_comp));
>  
> -		/* Ignore feature bits in Composition Compare */
> -		node_comp[8] = 0;
> -		attach_comp[8] = 0;
> -
> +		/* Verify only element/models composition */
>  		if (node_len != attach_len ||
> -				memcmp(node_comp, attach_comp, node_len)) {
> +				memcmp(&node_comp[offset], &attach_comp[offset],
> +							node_len - offset)) {
>  			l_debug("Failed to verify app's composition data");
>  			return false;
>  		}
Brian Gix May 14, 2020, 5:05 p.m. UTC | #2
full Patchset Applied

On Fri, 2020-05-08 at 17:00 -0700, Inga Stotland wrote:
> When attaching an existing node, verify only the "elements" part
> of device composition, i.e., skip verification of CID/PID/VID, CRPL
> and features.
> ---
>  mesh/node.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/mesh/node.c b/mesh/node.c
> index acda6d472..e3f9e52e3 100644
> --- a/mesh/node.c
> +++ b/mesh/node.c
> @@ -1378,7 +1378,7 @@ static bool check_req_node(struct managed_obj_request *req)
>  {
>  	uint8_t node_comp[MAX_MSG_LEN - 2];
>  	uint8_t attach_comp[MAX_MSG_LEN - 2];
> -
> +	uint16_t offset = 10;
>  	uint16_t node_len = node_generate_comp(req->node, node_comp,
>  							sizeof(node_comp));
>  
> @@ -1389,12 +1389,10 @@ static bool check_req_node(struct managed_obj_request *req)
>  		uint16_t attach_len = node_generate_comp(req->attach,
>  					attach_comp, sizeof(attach_comp));
>  
> -		/* Ignore feature bits in Composition Compare */
> -		node_comp[8] = 0;
> -		attach_comp[8] = 0;
> -
> +		/* Verify only element/models composition */
>  		if (node_len != attach_len ||
> -				memcmp(node_comp, attach_comp, node_len)) {
> +				memcmp(&node_comp[offset], &attach_comp[offset],
> +							node_len - offset)) {
>  			l_debug("Failed to verify app's composition data");
>  			return false;
>  		}
diff mbox series

Patch

diff --git a/mesh/node.c b/mesh/node.c
index acda6d472..e3f9e52e3 100644
--- a/mesh/node.c
+++ b/mesh/node.c
@@ -1378,7 +1378,7 @@  static bool check_req_node(struct managed_obj_request *req)
 {
 	uint8_t node_comp[MAX_MSG_LEN - 2];
 	uint8_t attach_comp[MAX_MSG_LEN - 2];
-
+	uint16_t offset = 10;
 	uint16_t node_len = node_generate_comp(req->node, node_comp,
 							sizeof(node_comp));
 
@@ -1389,12 +1389,10 @@  static bool check_req_node(struct managed_obj_request *req)
 		uint16_t attach_len = node_generate_comp(req->attach,
 					attach_comp, sizeof(attach_comp));
 
-		/* Ignore feature bits in Composition Compare */
-		node_comp[8] = 0;
-		attach_comp[8] = 0;
-
+		/* Verify only element/models composition */
 		if (node_len != attach_len ||
-				memcmp(node_comp, attach_comp, node_len)) {
+				memcmp(&node_comp[offset], &attach_comp[offset],
+							node_len - offset)) {
 			l_debug("Failed to verify app's composition data");
 			return false;
 		}