[PATCH BlueZ] mesh: Fix unpacking NetKey/AppKey 3-octet index combo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This fixes how we unpack 3-octet combination of NetKey and AppKey
indices received in the payload of AppKeyAdd/Update/Delete messages.

For example, if the config client sends a message to add AppKey with
index 0x456 bound to NetKey with index 0x123, the received packed
3-octet will be: 0x56 0x34 0x12
The fix takes into account the correct byte ordering when unpacking
indices.
---
 mesh/cfgmod-server.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c
index 55cc8e9eb..79538037c 100644
--- a/mesh/cfgmod-server.c
+++ b/mesh/cfgmod-server.c
@@ -1022,8 +1022,8 @@ static bool cfg_srv_pkt(uint16_t src, uint32_t dst, uint16_t unicast,
 		if (size != 19)
 			return true;
 
-		n_idx = l_get_le16(pkt) & 0xfff;
-		a_idx = l_get_le16(pkt + 1) >> 4;
+		n_idx = l_get_le16(pkt + 1) >> 4;
+		a_idx = l_get_le16(pkt) & 0xfff;
 
 		if (opcode == OP_APPKEY_ADD)
 			b_res = appkey_key_add(net, n_idx, a_idx, pkt + 3);
@@ -1048,9 +1048,10 @@ static bool cfg_srv_pkt(uint16_t src, uint32_t dst, uint16_t unicast,
 		if (size != 3)
 			return true;
 
-		n_idx = l_get_le16(pkt) & 0xfff;
-		a_idx = l_get_le16(pkt + 1) >> 4;
+		n_idx = l_get_le16(pkt + 1) >> 4;
+		a_idx = l_get_le16(pkt) & 0xfff;
 		b_res = appkey_key_delete(net, n_idx, a_idx);
+
 		l_debug("Delete AppKey %s Net_Idx %3.3x to App_Idx %3.3x",
 			(b_res == MESH_STATUS_SUCCESS) ? "success" : "fail",
 							n_idx, a_idx);
-- 
2.21.0




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux