diff --git a/src/app/clusters/ota-requestor/OTARequestor.cpp b/src/app/clusters/ota-requestor/OTARequestor.cpp index 79f32b50134bfa..4306721226afc8 100644 --- a/src/app/clusters/ota-requestor/OTARequestor.cpp +++ b/src/app/clusters/ota-requestor/OTARequestor.cpp @@ -554,12 +554,13 @@ CHIP_ERROR OTARequestor::SendQueryImageRequest(OperationalDeviceProxy & devicePr char location[DeviceLayer::ConfigurationManager::kMaxLocationLength]; size_t codeLen = 0; - if ((DeviceLayer::ConfigurationMgr().GetCountryCode(location, sizeof(location), codeLen) == CHIP_NO_ERROR) && (codeLen > 0)) + if ((DeviceLayer::ConfigurationMgr().GetCountryCode(location, sizeof(location), codeLen) == CHIP_NO_ERROR) && (codeLen == 2)) { args.location.SetValue(CharSpan(location, codeLen)); } else { + // Country code unavailable or invalid, use default args.location.SetValue(CharSpan("XX", strlen("XX"))); }