Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that attempts to read integers from TLV don't silently produce unexpected values. #9944

Merged
merged 1 commit into from
Sep 28, 2021

Conversation

bzbarsky-apple
Copy link
Contributor

Two changes:

  1. Ensure the value was encoded with the signed-ness the reader expects.

  2. Ensure the value is in the range the reader expects instad of
    ending up with overflow and whatever that does..

Fixes #5152

The test changes were largely lifted from
#5764

Problem

If the sender encoded 256 and the recipient reads it as a uint8_t, currently we will silently read 0.

Change overview

Make that fail instead.

Testing

Lots of new unit tests, courtesy of @bitkis

… unexpected values.

Two changes:

1) Ensure the value was encoded with the signed-ness the reader expects.

2) Ensure the value is in the range the reader expects instad of
   ending up with overflow and whatever that does..

Fixes project-chip#5152

The test changes were largely lifted from
project-chip#5764
@github-actions
Copy link

Size increase report for "gn_qpg-example-build" from 3647c29

File Section File VM
chip-qpg6100-lighting-example.out .text 96 96
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-qpg6100-lighting-example.out.map and ./pull_artifact/chip-qpg6100-lighting-example.out.map:

BLOAT EXECUTION FAILED WITH CODE 1:
bloaty: unknown file type for file './pull_artifact/chip-qpg6100-lighting-example.out.map'

Comparing ./master_artifact/chip-qpg6100-lighting-example.out and ./pull_artifact/chip-qpg6100-lighting-example.out:

sections,vmsize,filesize
.debug_info,0,897
.debug_line,0,232
.debug_str,0,192
.debug_loc,0,189
.text,96,96
.debug_abbrev,0,30
.debug_frame,0,4
[Unmapped],0,-96


@github-actions
Copy link

Size increase report for "esp32-example-build" from 3647c29

File Section File VM
chip-all-clusters-app.elf .flash.text 132 132
chip-all-clusters-app.elf .flash.rodata -32 -32
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-all-clusters-app.elf and ./pull_artifact/chip-all-clusters-app.elf:

sections,vmsize,filesize
.debug_info,0,640
.debug_line,0,304
.debug_str,0,193
.flash.text,132,132
.debug_frame,0,28
.debug_abbrev,0,10
.debug_loc,0,6
.riscv.attributes,0,3
.flash.rodata,-32,-32
.debug_ranges,0,-48
[Unmapped],0,-100


@woody-apple woody-apple merged commit f578417 into project-chip:master Sep 28, 2021
@bzbarsky-apple bzbarsky-apple deleted the tlv-integer-range branch September 28, 2021 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[TLV] TLVReader should take care of the range of integer values
7 participants