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

Plugin (dancingparticles) - Signed integer overflows #287

Open
kaixiong opened this issue Feb 18, 2023 · 0 comments
Open

Plugin (dancingparticles) - Signed integer overflows #287

kaixiong opened this issue Feb 18, 2023 · 0 comments
Labels

Comments

@kaixiong
Copy link
Member

kaixiong commented Feb 18, 2023

UBSAN spots two signed integer overflows in two places within its beatdetector class.

Found by UBSAN:

dancingparticles/signal.cpp:32:8: runtime error: signed integer overflow: 65408 * 65408 cannot be represented in type 'int'
dancingparticles/signal.cpp:33:8: runtime error: signed integer overflow: 47316 * 47316 cannot be represented in type 'int'

In beatdetector::beatdetector():

for(int i=0;i<NUM_BANDS;i++)
{
    uint16_t f = i<128 ? (i-128) :0;    // <--- f underflows to produce a large unsigned number when i < 128
    f = f*f/100;                        // <--- overflow #1
    f = f*f/30;                         // <--- overflow #2
    filter[i] =f;
    //      cout << f<<endl;
    filterpower+=f;
}

There is an identical issue in beatdetector::learnbeat().

@kaixiong kaixiong added the bug label Feb 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant