Sign in to follow this  

C Question

This topic is 3568 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am assuming the lack of type safety in C is the reason why I can do this?
char tst = {
    'a','b'
} ;

int main (int argc, const char * argv[]) {
    void (*fp)() ;
    fp = tst ;
}

In theory I can then load any array with binary code and execute it. I was reading how the windows kernel (use to or still does) overwrite function pointers in order to redirect execution flow to another function. This is quite interesting.

Share this post


Link to post
Share on other sites
Type safety wouldn't prevent that from happening.
The general solution for that problem/feature found in some security solutions is to prevent stack and heap execution.

Share this post


Link to post
Share on other sites

This topic is 3568 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this