@@ -114,8 +114,13 @@ void CommissionerDiscoveryController::OnUserDirectedCommissioningRequest(UDCClie
114
114
Platform::CopyString (mCurrentInstance , state.GetInstanceName ());
115
115
mPendingConsent = true ;
116
116
char rotatingIdString[Dnssd::kMaxRotatingIdLen * 2 + 1 ];
117
- Encoding::BytesToUppercaseHexString (state.GetRotatingId (), state.GetRotatingIdLength (), rotatingIdString,
118
- sizeof (rotatingIdString));
117
+ CHIP_ERROR err = Encoding::BytesToUppercaseHexString (state.GetRotatingId (), state.GetRotatingIdLength (), rotatingIdString,
118
+ sizeof (rotatingIdString));
119
+ if (err != CHIP_NO_ERROR)
120
+ {
121
+ ChipLogError (AppServer, " On UDC: could not convert rotating id to hex" );
122
+ rotatingIdString[0 ] = ' \0 ' ;
123
+ }
119
124
120
125
ChipLogDetail (Controller,
121
126
" ------PROMPT USER: %s is requesting permission to cast to this TV, approve? [" ChipLogFormatMEI
@@ -182,10 +187,16 @@ void CommissionerDiscoveryController::InternalOk()
182
187
return ;
183
188
}
184
189
185
- char rotatingIdString[Dnssd::kMaxRotatingIdLen * 2 + 1 ] = " " ;
186
- Encoding::BytesToUppercaseHexString (client->GetRotatingId (), client->GetRotatingIdLength (), rotatingIdString,
187
- sizeof (rotatingIdString));
188
- CharSpan rotatingIdSpan = CharSpan (rotatingIdString, strlen (rotatingIdString));
190
+ char rotatingIdBuffer[Dnssd::kMaxRotatingIdLen * 2 ];
191
+ size_t rotatingIdLength = client->GetRotatingIdLength ();
192
+ CHIP_ERROR err =
193
+ Encoding::BytesToUppercaseHexBuffer (client->GetRotatingId (), rotatingIdLength, rotatingIdBuffer, sizeof (rotatingIdBuffer));
194
+ if (err != CHIP_NO_ERROR)
195
+ {
196
+ ChipLogError (AppServer, " UX InternalOk: could not convert rotating id to hex" );
197
+ return ;
198
+ }
199
+ CharSpan rotatingIdSpan (rotatingIdBuffer, 2 * rotatingIdLength);
189
200
190
201
uint8_t targetAppCount = client->GetNumTargetAppInfos ();
191
202
if (targetAppCount > 0 )
@@ -360,10 +371,16 @@ void CommissionerDiscoveryController::InternalHandleContentAppPasscodeResponse()
360
371
// - if CommissionerPasscode, then call new UX method to show passcode, send CDC
361
372
if (passcode == 0 && client->GetCommissionerPasscode () && client->GetCdPort () != 0 )
362
373
{
363
- char rotatingIdString[Dnssd::kMaxRotatingIdLen * 2 + 1 ] = " " ;
364
- Encoding::BytesToUppercaseHexString (client->GetRotatingId (), client->GetRotatingIdLength (), rotatingIdString,
365
- sizeof (rotatingIdString));
366
- CharSpan rotatingIdSpan = CharSpan (rotatingIdString, strlen (rotatingIdString));
374
+ char rotatingIdBuffer[Dnssd::kMaxRotatingIdLen * 2 ];
375
+ size_t rotatingIdLength = client->GetRotatingIdLength ();
376
+ CHIP_ERROR err = Encoding::BytesToUppercaseHexBuffer (client->GetRotatingId (), rotatingIdLength, rotatingIdBuffer,
377
+ sizeof (rotatingIdBuffer));
378
+ if (err != CHIP_NO_ERROR)
379
+ {
380
+ ChipLogError (AppServer, " UX Ok - HandleContentAppPasscodeResponse: could not convert rotating id to hex" );
381
+ return ;
382
+ }
383
+ CharSpan rotatingIdSpan (rotatingIdBuffer, 2 * rotatingIdLength);
367
384
368
385
// first step of commissioner passcode
369
386
ChipLogError (AppServer, " UX Ok: commissioner passcode, sending CDC" );
0 commit comments