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 __darwin_fflush() #6

Closed
giantpune opened this issue Apr 2, 2012 · 1 comment
Closed

segfault in __darwin_fflush() #6

giantpune opened this issue Apr 2, 2012 · 1 comment

Comments

@giantpune
Copy link

i was trying to use maloader to run a CLI OSx binary on kubuntu 11.10, 64bit. The program starts up and is able to show its basic usage to the console. however, it crashes when trying to use it to do more stuff. using gdb, i tracked the crash back to "int __darwin_fflush(__darwin_FILE* fp)". it is somehow being passed a NULL pointer, which isnt handled, and leads to a segfault. changing this function to check for NULL pointer fixes the crash and the program runs normally.

the man page for fflush() says that it is supposed to handle NULL pointer as a special case.
http://www.manpagez.com/man/3/fflush/

this is how i have changed it in my own code. i havents actually looked into how maloader is working, so it may be completely wrong.

int __darwin_fflush(__darwin_FILE* fp) {
if( !fp )
{
return fflush( NULL );
}
return fflush(fp->linux_fp);
}

@shinh shinh closed this as completed Apr 2, 2012
@shinh
Copy link
Owner

shinh commented Apr 2, 2012

You are absolutely right and your fix looks great, too. I've pushed the fix with a test case.

49c5ccc

Thanks for the report!

genose pushed a commit to genose/genose-port-contrib-Mach-o-loader that referenced this issue Oct 26, 2016
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