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: Accessing an array out of bounds in CECDeviceParams (Plugin::HdmiCecSink) #5933

Open
npoltorapavlo opened this issue Dec 11, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@npoltorapavlo
Copy link
Contributor

Problem/Opportunity

CECDeviceParams class inits "Language m_currentLanguage;" with empty string: "".
Language constructor passes empty string "" and constant "MAX_LEN = 3" to CECBytes constructor that iterates through the empty buffer 3 times. Accessing an array out of bounds gives no error, but causes Undefined Behavior / SIGSEGV.

: m_deviceType(0), m_logicalAddress(0),m_physicalAddr(0x0f,0x0f,0x0f,0x0f),m_cecVersion(0),m_vendorID(0,0,0),m_osdName(""),m_powerStatus(0),m_currentLanguage("")

    enum {
        MAX_LEN = 3,
    };
    Language(const char *str) : CECBytes((const uint8_t*)str, MAX_LEN) {
        validate();
    } 
 	CECBytes(const uint8_t *buf, size_t len) {
        if (buf && len) {
            for (size_t i = 0; i < len; i++) {
                str.push_back(buf[i]);
            }
        }
	}

Steps to reproduce

Build/run with ASAN.

Expected Behavior

No Undefined Behavior / SIGSEGV.

Actual Behavior

SIGSEGV

Notes (Optional)

No response

@npoltorapavlo npoltorapavlo added the bug Something isn't working label Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant