1 #include <stdio.h>
2 #include <stdlib.h>
3
4 void Bug ()
5 {
6 System ("reboot");
7 exit (0);
8}
9 int stack_test (int a,int b)
10 {
//int *p=&a;
//p--;
//*p=bug;
printf ("Before write:0x%x\n", b);
*p=&a; int
p++;
*P=0XDDDD;
printf ("After write:0x%x\n", b);
C=0XCCCC int;
return C;
21}
int main ()
23 {
A=0XAAAA int;
B=0XBBBB int;
Ret=stack_test Int (A, b);
printf ("You should run here\n");
return 0;
29}
The result of the program operation is:
Before WRITE:0XBBBB
After WRITE:0XDDDD
Should run here
The bug function restarts the system;
The reason for the change in the value of B: function parameters in the stack when the right-to-left, so B on the next A on, the pointer p to a, p at + + point to the B, so change the value of the pointer p will change the value of B
This article is from the "fringe" blog, so be sure to keep this source http://ab6107.blog.51cto.com/10538332/1761446
Modify the value of a variable while the program is running under Linux