postPairingsURL - fix controller update

ensure updating existing controller does retain original permissions
This commit is contained in:
Daniel Skowroński 2022-10-26 21:20:09 +02:00
parent 62e6913dc2
commit cb0b722bb1
No known key found for this signature in database
GPG Key ID: E33828259A4A062D
1 changed files with 2 additions and 1 deletions

View File

@ -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=<M2>
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
}