Skip to content

feat: decode BER-OID key into int (KLV::getTagAsInt)#7

Merged
r00t6-k merged 3 commits intomasterfrom
feat/decode-ber-oid-tag
Apr 27, 2026
Merged

feat: decode BER-OID key into int (KLV::getTagAsInt)#7
r00t6-k merged 3 commits intomasterfrom
feat/decode-ber-oid-tag

Conversation

@r00t6-k
Copy link
Copy Markdown
Contributor

@r00t6-k r00t6-k commented Apr 23, 2026

Summary

  • Adds KLV::getTagAsInt(uint64_t& out) — validates BER-OID continuation structure, caps at 10 bytes, and rejects any accumulation that would overflow uint64_t.
  • Drops the TODO at KlvParser.cpp:90 that flagged exactly this gap.
  • Updates the stale "only 16-byte keys supported" class-level doc.

Why

libklv handed the raw key bytes through without decoding, forcing every consumer to re-implement the same 7-bit accumulate. This closes that gap on the class itself with proper validation so hand-constructed KLVs can't silently produce garbage.

Test plan

  • 9 tests in KlvTest.cpp pass (built against brew googletest 1.17, C++17): the 1 pre-existing case plus 8 new cases covering single-byte, multi-byte, empty key, universal-key rejection, malformed continuation (both directions), full uint64_t range, and overflow rejection.
  • Downstream AMC integration (Auterion/auterion-qgroundcontrol#6175) consumes this via child->getTagAsInt(tag).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a convenience API on KLV to decode BER-OID (base-128) encoded keys into an integer, addressing a previously noted gap in the parser and adding unit tests to exercise the new behavior.

Changes:

  • Add KLV::getTagAsInt(uint64_t& out) to accumulate 7-bit BER-OID key bytes into a uint64_t.
  • Remove the BER-OID “human-readable tag” TODO from KlvParser.
  • Add TEST_F coverage for single-byte, multi-byte, empty-key, and oversized-key rejection scenarios.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/Klv.cpp Implements KLV::getTagAsInt BER-OID-to-uint64_t decoder.
include/Klv.h Exposes the new getTagAsInt API and documents its return behavior.
src/KlvParser.cpp Removes obsolete TODO related to BER-OID tag decoding.
test/KlvTest.cpp Adds new unit tests for getTagAsInt behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Klv.cpp
Comment thread include/Klv.h Outdated
Comment thread test/KlvTest.cpp Outdated
Comment thread test/KlvTest.cpp
@r00t6-k r00t6-k force-pushed the feat/decode-ber-oid-tag branch 2 times, most recently from fac8090 to 17d3866 Compare April 24, 2026 09:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Klv.cpp
Comment thread include/Klv.h
Comment thread test/KlvTest.cpp
@r00t6-k r00t6-k force-pushed the feat/decode-ber-oid-tag branch from 17d3866 to cf34d17 Compare April 24, 2026 18:30
Fills the gap the parser's own TODO flagged; consumers no longer
re-implement the 7-bit accumulate.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Klv.cpp Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@r00t6-k r00t6-k merged commit f9fdb8e into master Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants