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

Fixed stack memory corruption due to strcat() function #21

Merged
merged 6 commits into from
Mar 18, 2024

Conversation

DartFNM
Copy link
Contributor

@DartFNM DartFNM commented Mar 17, 2024

  • The problem with memory stack corruption occurred in the 'fetch_saveimagepath()' function when starting the emulator. Because the memory allocated on the stack TCHAR path[MAX_DPATH] in function DISK_get_default_saveimagepath does not have a end of line marker ('/0'). That's why further call of the strcat() function which first searches for a zero byte and then adds another string to it resulted in stack corruption in this place and application crash as a consequence.
    In other similar functions, the same scenario is possible.

I'm sorry, seems to I don't really know GitHub yet.
Because I made second comit with the optional enabling of SSE3 instructions (like 'movbe'). But they merged into one pull-request.

DartFNM and others added 5 commits March 17, 2024 18:28
- The problem with memory stack corruption occurred in the 'fetch_saveimagepath()' function when starting the emulator.
Because the memory allocated on the stack `TCHAR path[MAX_DPATH]` in function `DISK_get_default_saveimagepath` does not have a end of line marker ('/0').
That's why further call of the strcat() function which first searches for a zero byte and then adds another string to it resulted in stack corruption in this place and application crash as a consequence.
- In other similar functions, the same scenario is possible.
Compilation error, I forgot to specify the variable name
- The problem with memory stack corruption occurred in the 'fetch_saveimagepath()' function when starting the emulator.
Because the memory allocated on the stack `TCHAR path[MAX_DPATH]` in function `DISK_get_default_saveimagepath` does not have a end of line marker ('/0').
That's why further call of the strcat() function which first searches for a zero byte and then adds another string to it resulted in stack corruption in this place and application crash as a consequence.
- In other similar functions, the same scenario is possible.
- My Intel processor 2011 does not support SSE3 extensions, in particular 'movbe' instruction. As a result, the emulator crashes with the error 'illegal instruction'
Therefore, I would recommend leaving the original #ifdef HAVE_MOVBE
@emoon
Copy link
Member

emoon commented Mar 17, 2024

Thanks for the fixes. As you can see lots of the code in dummy.cpp hasn't been fully implemented yet.

@emoon emoon merged commit 73b8932 into theblacklotus:main Mar 18, 2024
15 checks passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants