From 2016866227691f2724f9557b5337c405ec084140 Mon Sep 17 00:00:00 2001 From: Sergei Lissianoi <54454955+selissia@users.noreply.github.com> Date: Fri, 28 Jan 2022 09:51:22 -0500 Subject: [PATCH] Use default country code in QueryImage if the local value is corrupted (#14501) --- src/app/clusters/ota-requestor/OTARequestor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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"))); }