From cb0b722bb1fe849192eabd739801ef19e45bbdd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Skowro=C5=84ski?= Date: Wed, 26 Oct 2022 21:20:09 +0200 Subject: [PATCH] postPairingsURL - fix controller update ensure updating existing controller does retain original permissions --- src/HAP.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/HAP.cpp b/src/HAP.cpp index c4b2844..3aa98ab 100644 --- a/src/HAP.cpp +++ b/src/HAP.cpp @@ -931,10 +931,11 @@ int HAPClient::postPairingsURL(){ } if((newCont=findController(tlv8.buf(kTLVType_Identifier)))){ + int originalPermissions=tlv8.val(kTLVType_Permissions); tlv8.clear(); // clear TLV records tlv8.val(kTLVType_State,pairState_M2); // set State= if(!memcmp(cPair->LTPK,newCont->LTPK,32)){ // requested Controller already exists and LTPK matches - newCont->admin=tlv8.val(kTLVType_Permissions)==1?true:false; // update permission of matching Controller + newCont->admin=originalPermissions==1?true:false; // update permission of matching Controller } else { tlv8.val(kTLVType_Error,tagError_Unknown); // set Error=Unknown }