Skip to content

Conversation

@gburgessiv
Copy link
Contributor

libcxx hardening was breaking in kati's tests, since TrimLeftSpace(cur_) may return an empty string_view, and we're unconditionally accessing [0] after that.

It looks like the code that follows the while loop gracefully handles empty strings, so add a simple check for empty() that falls through to that.

Test: Android: prebuilts/build-tools/build-prebuilts.sh now passes

libcxx hardening was breaking in kati's tests, since
`TrimLeftSpace(cur_)` may return an empty string_view, and we're
unconditionally accessing `[0]` after that.

It looks like the code that follows the `while` loop gracefully handles
empty strings, so add a simple check for `empty()` that falls through to
that.

Test: Android: `prebuilts/build-tools/build-prebuilts.sh` now passes
@gburgessiv
Copy link
Contributor Author

Some of the kati unittests failed on my machine on main (seems I have a mismatched make version, among other things). Seems CI will verify for me once approval is given, so sending for review hoping that goes well :)

If not, happy to pull docker on a personal machine and iterate.

@gburgessiv gburgessiv marked this pull request as ready for review December 2, 2025 15:06
@gburgessiv gburgessiv requested a review from a team as a code owner December 2, 2025 15:06
@gburgessiv
Copy link
Contributor Author

/cc @colincross @Colecf

Copy link
Collaborator

@danw danw left a comment

Choose a reason for hiding this comment

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

I'm slightly surprised you didn't run into an out-of-bounds read in expr.cc:ParseDollar too -- in order to properly parse things it reads past the end of the string view. I noticed that while working the rust implementation, which adds another boolean argument to that function (src-rs/expr.rs)

@danw danw merged commit ec1814e into google:master Dec 2, 2025
2 checks passed
@gburgessiv
Copy link
Contributor Author

Thanks for the quick review & merge! Yeah, not sure why that wasn't hit, but the hardening check introduction is still pretty early stages. Maybe I'll bump into that in the coming weeks, as the presubmits turn a bit greener. :)

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.

2 participants