Skip to content

[TLV Read] - fix read resetting empty TLV data (backport #43182)#72389

Open
mergify[bot] wants to merge 1 commit into
v1.4.2-branchfrom
mergify/bp/v1.4.2-branch/pr-43182
Open

[TLV Read] - fix read resetting empty TLV data (backport #43182)#72389
mergify[bot] wants to merge 1 commit into
v1.4.2-branchfrom
mergify/bp/v1.4.2-branch/pr-43182

Conversation

@mergify
Copy link
Copy Markdown
Contributor

@mergify mergify Bot commented Jun 3, 2026

Summary

  • TLV getting data pointer returns null on empty length:
CHIP_ERROR TLVReader::GetDataPtr(const uint8_t *& data) const
{
    VerifyOrReturnError(TLVTypeIsString(ElementType()), CHIP_ERROR_WRONG_TLV_TYPE);

    if (GetLength() == 0)
    {
        data = nullptr;
        return CHIP_NO_ERROR;
    }
    ...

This results in checks for data pointer to early return and were failing to reset the CharSpan to an empty value. This breaks any code that assumes a successful read will reset the data (which seems reasonable).

We mostly did not see it because we often initialize CharSpan and then read. Correctness-wise though, a successfull read should update the read target.

Testing

CI tests updated to a test that would catch this bug (tested that it would fail before the fix)


This is an automatic backport of pull request #43182 done by Mergify.

* Fix TLV reading of empty data.

* Update LSID.

* Cleanup test.

(cherry picked from commit 9edc95e)
@mergify mergify Bot added the backport-v1.4.2-branch Backport PR targeting v1.4.2-branch, created by Mergify label Jun 3, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

PR #72389: Size comparison from 09d0453 to 5fec415

Full report (14 builds for cc13x4_26x4, cc32xx, nrfconnect, qpg, stm32, tizen)
platform target config section 09d0453 5fec415 change % change
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 764852 764860 8 0.0
RAM 103376 103376 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 776656 776664 8 0.0
RAM 108560 108560 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 722620 722628 8 0.0
RAM 96948 96948 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 706912 706920 8 0.0
RAM 97156 97156 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 550146 550146 0 0.0
RAM 205176 205176 0 0.0
lock CC3235SF_LAUNCHXL FLASH 583386 583394 8 0.0
RAM 205384 205384 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 916480 916488 8 0.0
RAM 167458 167458 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 FLASH 859992 860000 8 0.0
RAM 141065 141065 0 0.0
all-clusters-app nrf7002dk_nrf5340_cpuapp FLASH 914452 914460 8 0.0
RAM 145676 145676 0 0.0
qpg lighting-app qpg6200+debug FLASH 745088 745104 16 0.0
RAM 94228 94228 0 0.0
lock-app qpg6200+debug FLASH 755044 755044 0 0.0
RAM 94264 94264 0 0.0
stm32 light STM32WB5MM-DK FLASH 466512 466520 8 0.0
RAM 141376 141376 0 0.0
tizen all-clusters-app arm unknown 5308 5308 0 0.0
FLASH 1822368 1822392 24 0.0
RAM 97556 97556 0 0.0
chip-tool-ubsan arm unknown 20700 20700 0 0.0
FLASH 20976754 20976874 120 0.0
RAM 9131396 9131460 64 0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-v1.4.2-branch Backport PR targeting v1.4.2-branch, created by Mergify core lib

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant