LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   three lines of code ... (https://www.linuxquestions.org/questions/programming-9/three-lines-of-code-678596/)

Filipe 10-23-2008 12:30 PM

three lines of code ...
 
I am reading the "Buffer Overflow Attacks" and i cannot understand
three simple (i think) lines of code:

(code = malloc(flen))



50 void (*fptr)(void);
...
64 fptr = (void (*)(void)) code;
65 (*fptr)();



in 50 i presume tht fptr is a pointer to a function that has one void argument and returns a void...
is this true?
and what about line 64 and 65 ... they puzzled me...


any help ?
Thank you very much!

bgeddy 10-23-2008 12:38 PM

Line 64 is setting fptr to code with a cast so code is being cast to a pointer to a function taking and returning a void.

Line 65 is calling the function pointed to by fptr.


All times are GMT -5. The time now is 03:48 AM.