well, the function gets(), reads char until the user press <enter>, right?
the function fgets(), reads char from a file until apear '\n' or '\0'?
plz explain me this
well, the function gets(), reads char until the user press <enter>, right?
the function fgets(), reads char from a file until apear '\n' or '\0'?
plz explain me this
Whats to explain? fgets can read in from the keyboard as well - as
in it will read in until is reads an enter key (or the buffer its writing
to gets full). The '\n' character is the same as pressing enter - the
computer sees enter as an ASCII character. As for '\0' thats the
string termination character - it won't cause fgets to stop reading
I think.
No No's:
fflush (stdin); gets (); void main ();
Goodies:
Example of fgets (); The FAQ, C/C++ Reference
My Gear:
OS - Windows XP
IDE - MS Visual C++ 2008 Express Edition
ASCII stupid question, get a stupid ANSI
Some of you know what buffer expliots are...
well....gets is the buggy one that is unsafe....even the compiler tells you i think...
and fgets...or something like that is a revised version...
In gets, you specified the buffer length.....
So lets say you said you got a size of 12....
AND
ANSI is encoded in basically, a character per a byte....
So you have a 12 byte buffer, + 4 bytes for prog stack ops, and then return address from call.
SO, using gets, you can convert assembly code instructions, and a return address to execute, in fact, the string in gets as assembly code.....
You can compile your assembly into object code and then dump it to get hex instructions, and then just tag on the return address(the address of gets in the buffer which can be found using GDB) and the program will execute you exploit code...
Basically, thats how a hack is made....
If your really good, you'll patch the stack during your exploit so the prog doesnt even know it did something wrong and wont segfault.....
fgets fixes that....or some other gets function....i dont remember.....c was a while back...
Fgets() and gets() are two different functions. Gets() is never a macro like printf() can be.
fgets() also takes an aditional length paramitter. Prototypes:Originally Posted by iRMX® C Library Reference, on gets
char *fgets (char *string, int n, FILE *stream);
char *gets (char *buffer);
>plz explain me this
It's very simple, really. gets is a figment of your imagination. fgets is what we use to read a line from a stream.
My best code is written with the delete key.