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

malloc(0) and divide by zero #50

Closed
cuanduo opened this issue Jan 14, 2019 · 1 comment
Closed

malloc(0) and divide by zero #50

cuanduo opened this issue Jan 14, 2019 · 1 comment
Labels

Comments

@cuanduo
Copy link

cuanduo commented Jan 14, 2019

if we set SampleRate = 0; in vgmplay.ini will cause divide by zero
as follows

Program received signal SIGFPE, Arithmetic exception.
0x0000555555564274 in SamplePbk2VGM_I (SampleVal=0) at VGMPlay.c:3969
3969		return (INT32)((INT64)SampleVal * VGMSmplRateDiv / VGMSmplRateMul);
(gdb) bt
#0  0x0000555555564274 in SamplePbk2VGM_I (SampleVal=0) at VGMPlay.c:3969
#1  0x00005555555650a5 in InterpretVGM (SampleCount=0) at VGMPlay.c:4741
#2  0x0000555555564487 in InterpretFile (SampleCount=0) at VGMPlay.c:4178
#3  0x000055555555c427 in PlayVGM () at VGMPlay.c:1058
#4  0x000055555555a6d7 in PlayVGM_UI () at VGMPlayUI.c:2132
#5  0x0000555555556d25 in main (argc=3, argv=0x7fffffffe048) at VGMPlayUI.c:530
(gdb) p VGMSmplRateMul 
$20 = 0

if set SampleRate = 1; and commandline with -LogSound:1 will cause malloc(0) and may cause heap overflow

Breakpoint 6, __GI___libc_malloc (bytes=0) at malloc.c:3028
3028	malloc.c: No such file or directory.
(gdb) bt
#0  __GI___libc_malloc (bytes=0) at malloc.c:3028
#1  0x000055555555a96e in PlayVGM_UI () at VGMPlayUI.c:2222
#2  0x0000555555556d25 in main (argc=3, argv=0x7fffffffe048) at VGMPlayUI.c:530
@cuanduo cuanduo changed the title malloc(0) and divide by zero malloc(0) and divide by zero Jan 14, 2019
@ValleyBell
Copy link
Contributor

Well, if you want to break VGMPlay, there are more creative ways to do it. Like partially broken VGMs, for example.
Setting the sample rate to anything smaller than 1000 won't result in any useful sound anyway.

So I consider this a "not worth fixing", as nobody sane would use those configurations. (And I verified that with SampleRate = 1, the buffer is never used.)

I also edited your post with code blocks, so that it doesn't do unwanted references to other issues.

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

2 participants