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

[BUG] Likely use after free when looking at setupPin in ContentAppCommandDelegate #30155

Open
andy31415 opened this issue Nov 1, 2023 · 0 comments
Assignees
Labels
android bug Something isn't working memory tv TV-related features tv-casting

Comments

@andy31415
Copy link
Contributor

Reproduction steps

see #29944 (comment)

Code is:

if (!value[setupPINFieldId].empty())
{
    getSetupPINresponse.setupPIN = CharSpan::fromCharString(value[setupPINFieldId].asCString());
    // ...

that c-str may not be available once value goes out of scope.
Overall https://github.com/project-chip/connectedhomeip/blob/master/examples/tv-app/android/java/ContentAppCommandDelegate.cpp seems to be using this pattern quite frequently and we should validate if it is safe (and comment on the lifetime of the c_string, as https://open-source-parsers.github.io/jsoncpp-docs/doxygen/class_json_1_1_value.html#a7d99f5dba388cdaa152ce6ef933d64ef says that operator[] just returns a value, so I assume the cstring only lives as long as that value lives.

Bug prevalence

ALWAYS

GitHub hash of the SDK that was being used

db9fc87

Platform

android

Platform Version(s)

No response

Anything else?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android bug Something isn't working memory tv TV-related features tv-casting
Projects
Status: Todo
Status: Todo
Development

No branches or pull requests

5 participants