LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-23-2008, 12:30 PM   #1
Filipe
LQ Newbie
 
Registered: Dec 2005
Posts: 23

Rep: Reputation: 15
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!
 
Old 10-23-2008, 12:38 PM   #2
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 232Reputation: 232Reputation: 232
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl vs. bash code - number of lines noir911 Programming 11 10-07-2011 12:35 PM
LXer: VIA Gives 16,434 Lines Of OSS Code LXer Syndicated Linux News 0 05-09-2008 11:10 AM
[Discussion] Ten Lines of Code or Less taylor_venable Programming 17 12-12-2006 05:55 AM
adding code lines Qwo Linux From Scratch 17 05-24-2006 02:58 AM
How to count how many lines of code my project is? The_Nerd Programming 4 08-30-2004 08:26 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration