You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Surface integrity-check failure when parsing a bad setup payload
A Manual Pairing Code with a wrong Verhoeff check digit causes
ManualSetupPayloadParser::populatePayload to return
CHIP_ERROR_INTEGRITY_CHECK_FAILED, but the MTR layer was discarding the
specific code: -[MTRSetupPayload initWithManualPairingCode:] dropped it on
the floor (no error out-param), and downstream call sites
(+setupPayloadWithOnboardingPayload:error:,
-[MTRManualSetupPayloadParser populatePayload:],
-[MTRDeviceController pairDevice:onboardingPayload:error:]) all flattened
parse failures to MTRErrorCodeInvalidArgument. Callers had no way to tell
"the user typed a bad setup code" apart from any other parse error.
Adversarial audit found the QR Code parse path had the same shape:
-[MTRSetupPayload initWithQRCode:] has no error out-param,
-[MTRQRCodeSetupPayloadParser populatePayload:] discards the specific
CHIP_ERROR and rewrites it to MTRErrorCodeInvalidArgument, and the QR
branch of +setupPayloadWithOnboardingPayload:error: does the same.
A scanner glitch or a typed-in QR string with a bad Base38 character
or invalid chunk length was indistinguishable from any other parse
failure, so callers stalled the same way.
Add NSError**-bearing -initWithManualPairingCode:error: and
-initWithQRCode:error: variants that map the underlying CHIP_ERROR
via [MTRError errorForCHIPErrorCode:], and route the downstream call
sites through them:
- -[MTRManualSetupPayloadParser populatePayload:]
- -[MTRQRCodeSetupPayloadParser populatePayload:]
- +[MTRSetupPayload setupPayloadWithOnboardingPayload:error:] (both
the QR and manual branches collapse to a single dispatch)
- -[MTRDeviceController pairDevice:onboardingPayload:error:]
The existing no-error inits are preserved as thin wrappers for
source compatibility. The CHIP_ERROR -> MTRError mappings already
exist in MTRError.mm (CHIP_ERROR_INTEGRITY_CHECK_FAILED ->
MTRErrorCodeIntegrityCheckFailed, CHIP_ERROR_INVALID_INTEGER_VALUE
-> MTRErrorCodeInvalidIntegerValue, CHIP_ERROR_INVALID_STRING_LENGTH
-> MTRErrorCodeInvalidStringLength); no new error codes are needed.
Adds XCTests against MTRSetupPayloadTests.m pinning the new error
shape across both parse paths:
- bad Verhoeff check digit -> MTRErrorCodeIntegrityCheckFailed
- bad Base38 character -> MTRErrorCodeInvalidIntegerValue
- invalid Base38 chunk length -> MTRErrorCodeInvalidStringLength
and a MTRPairingBackwardsCompatTests integration pin on the
pairDevice:onboardingPayload:error: surface. The existing C++
regression guard (TestManualCode.TestPayloadParser_InvalidEntry)
is left intact.
NFC commissioning shares the QR parse path (the NFC tag carries a
Matter-encoded URL whose payload portion is the same Base38 QR string),
so this fix covers NFC payload failures too.
0 commit comments