-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* ===================================================================================== | ||
* | ||
* Filename: echo.c | ||
* | ||
* Description: echo | ||
* | ||
* Version: 1.0 | ||
* Created: 10/21/2011 09:14:08 PM | ||
* Revision: none | ||
* Compiler: gcc | ||
* | ||
* Author: Fu Haiping | ||
* Company: ICT | ||
* | ||
* ===================================================================================== | ||
*/ | ||
/* Echo Line */ | ||
#include <stdio.h> | ||
void echo() | ||
{ | ||
char buf[4]; | ||
gets(buf); | ||
puts(buf); | ||
} | ||
|
||
int main(int argc, const char *argv[]) | ||
{ | ||
echo(); | ||
return 0; | ||
} | ||
|
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* ===================================================================================== | ||
* | ||
* Filename: exploit.c | ||
* | ||
* Description: simple exploit | ||
* | ||
* Version: 1.0 | ||
* Created: 10/21/2011 09:19:42 PM | ||
* Revision: none | ||
* Compiler: gcc | ||
* | ||
* Author: Fu Haiping | ||
* Company: ICT | ||
* | ||
* ===================================================================================== | ||
*/ | ||
|
||
#include <stdio.h> | ||
|
||
void echo() | ||
{ | ||
printf("hello in echo.\n"); | ||
} | ||
|
||
|
||
void callee() | ||
{ | ||
printf("hello in caller.\n"); | ||
} | ||
void caller() | ||
{ | ||
int dummy[3]; | ||
callee(); | ||
printf("done in callee.\n"); | ||
} | ||
|
||
int main(int argc, const char * argv[]) | ||
{ | ||
caller(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* ===================================================================================== | ||
* | ||
* Filename: time-consume.c | ||
* | ||
* Description: a time-comsuming application. | ||
* | ||
* Version: 1.0 | ||
* Created: 10/25/2011 10:07:20 AM | ||
* Revision: r1 | ||
* Compiler: gcc | ||
* | ||
* Author: Fu Haiping | ||
* Company: ICT | ||
* | ||
* ===================================================================================== | ||
*/ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
|
||
int a(void) | ||
{ | ||
int i=0,g=0; | ||
while(i++<100000) | ||
{ | ||
g+=i; | ||
} | ||
return g; | ||
} | ||
|
||
int b(void) | ||
{ | ||
int i=0,g=0; | ||
while(i++<400000) | ||
{ | ||
g+=i; | ||
} | ||
return g; | ||
} | ||
int main(int argc, char** argv) | ||
{ | ||
int iterations; | ||
if(argc != 2) | ||
{ | ||
printf("Usage %s <No of Iterations>\n", argv[0]); | ||
exit(-1); | ||
} | ||
else | ||
iterations = atoi(argv[1]); | ||
printf("No of iterations = %d\n", iterations); | ||
while(iterations--) | ||
{ | ||
a(); | ||
b(); | ||
} | ||
} |