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

Segfault in getString #21

Open
holyfuchs opened this issue Aug 12, 2023 · 1 comment
Open

Segfault in getString #21

holyfuchs opened this issue Aug 12, 2023 · 1 comment

Comments

@holyfuchs
Copy link

Trying to parse for example the following result results in a buffer underflow of lengthIndex.

{"jsonrpc":"2.0","id":0,"result":"0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000005468747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f6c6f72626b652f426c6f636b426f6172642f6d61696e2f6173736574732f64656661756c745f68617264776172652e676966000000000000000000000000"}
    while (lengthIndex > 0)
    {
        Serial.println(index);
        asciiHex += v->at(index++);
        lengthIndex -= 32;
    }

checking if lengthIndex is smaller than 32 before subtracting or changing lengthIndex to a signed int fixes the segfault

@JamesSmartCell
Copy link
Member

Thanks @Bluegales I'll take a look

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

No branches or pull requests

2 participants