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

Scanf problems #4756

Closed
shlyakpavel opened this issue Jan 3, 2019 · 5 comments
Closed

Scanf problems #4756

shlyakpavel opened this issue Jan 3, 2019 · 5 comments

Comments

@shlyakpavel
Copy link
Contributor

PVS studio warning: V614 Uninitialized buffer 's' used. Consider checking the first actual argument of the 'sscanf' function.

if(sscanf(s, "%f", &envpts[env][0][ep])==0) envpts[env][0][ep] = 0.f;

@zonkmachine
Copy link
Member

If I remember correctly, DrumSynth files do crash directly on exit when debugging on the master branch with the floating point exceptions set. Could be this? I never got around to debug it.

@PhysSong
Copy link
Member

PhysSong commented Jan 5, 2019

The code is supposed to work with valid DrumSynth files since the else clause initializes s first. With valid files, en should look like this: 0,0 2,4 12,0.
The GetEnv function, however, has several problems. With an invalid file which gives en like ,AAAAAAAAAAAAAAA AAAAAAA, the function will suffer from garbage values and buffer overrun.
IMO this function might be considered as a security vulnerability as well.

@PhysSong
Copy link
Member

PhysSong commented Jan 5, 2019

The problem with GetEnv doesn't look that much severe when I tested with some manually corrupted files, but I'm not sure if we can leave the code as-is.

@shlyakpavel
Copy link
Contributor Author

@PhysSong I agree it's vulnerable so this should not be left "as is".

@M374LX
Copy link
Contributor

M374LX commented Mar 2, 2019

This might be solved by adding the line
s[0]=0;
right after
en[255]=0; //be safe!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants