File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
src/include/platform/internal Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -673,15 +673,31 @@ CHIP_ERROR GenericConfigurationManagerImpl<ConfigClass>::GetCommissionableDevice
673673template <class ConfigClass >
674674CHIP_ERROR GenericConfigurationManagerImpl<ConfigClass>::GetInitialPairingInstruction(char * buf, size_t bufSize)
675675{
676- VerifyOrReturnError (bufSize >= sizeof (CHIP_DEVICE_CONFIG_PAIRING_INITIAL_INSTRUCTION), CHIP_ERROR_BUFFER_TOO_SMALL);
676+ constexpr size_t kLiteralSize = sizeof (CHIP_DEVICE_CONFIG_PAIRING_INITIAL_INSTRUCTION);
677+ constexpr bool kIsLiteralEmpty = (kLiteralSize == 1 ); // Only the null terminator is present, the literal is "" (empty-string)
678+
679+ if (kIsLiteralEmpty )
680+ {
681+ return CHIP_ERROR_NOT_FOUND;
682+ }
683+
684+ VerifyOrReturnError ((bufSize >= kLiteralSize ), CHIP_ERROR_BUFFER_TOO_SMALL);
677685 strcpy (buf, CHIP_DEVICE_CONFIG_PAIRING_INITIAL_INSTRUCTION);
678686 return CHIP_NO_ERROR;
679687}
680688
681689template <class ConfigClass >
682690CHIP_ERROR GenericConfigurationManagerImpl<ConfigClass>::GetSecondaryPairingInstruction(char * buf, size_t bufSize)
683691{
684- VerifyOrReturnError (bufSize >= sizeof (CHIP_DEVICE_CONFIG_PAIRING_SECONDARY_INSTRUCTION), CHIP_ERROR_BUFFER_TOO_SMALL);
692+ constexpr size_t kLiteralSize = sizeof (CHIP_DEVICE_CONFIG_PAIRING_SECONDARY_INSTRUCTION);
693+ constexpr bool kIsLiteralEmpty = (kLiteralSize == 1 ); // Only the null terminator is present, the literal is "" (empty-string)
694+
695+ if (kIsLiteralEmpty )
696+ {
697+ return CHIP_ERROR_NOT_FOUND;
698+ }
699+
700+ VerifyOrReturnError ((bufSize >= kLiteralSize ), CHIP_ERROR_BUFFER_TOO_SMALL);
685701 strcpy (buf, CHIP_DEVICE_CONFIG_PAIRING_SECONDARY_INSTRUCTION);
686702 return CHIP_NO_ERROR;
687703}
You can’t perform that action at this time.
0 commit comments