summaryrefslogtreecommitdiff
path: root/cil/doc/examples/ex24.txt
blob: 587ce674d8ce0f74829b4e5921f11c8632bd20af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* Generated by CIL v. 1.3.5 */
/* print_CIL_Input is true */

extern void * stackguard_get_ra();
extern void stackguard_set_ra(void *new_ra);
/* You must provide an implementation for functions that get and set the
 * return address. Such code is unfortunately architecture specific.
 */
struct stackguard_stack {
  void * data;
  struct stackguard_stack * next;
} * stackguard_stack;

void stackguard_push(void *ra) {
  void * old = stackguard_stack;
  stackguard_stack = (struct stackguard_stack *)
    malloc(sizeof(stackguard_stack));
  stackguard_stack->data = ra;
  stackguard_stack->next = old;
}

void * stackguard_pop() {
  void * ret = stackguard_stack->data;
  void * next = stackguard_stack->next;
  free(stackguard_stack);
  stackguard_stack->next = next;
  return ret;
}
#line 3 "cilcode.tmp/ex24.c"
extern int ( /* missing proto */  scanf)() ;
#line 1 "cilcode.tmp/ex24.c"
int dangerous(void) 
{ char array[10] ;
  void *return_address ;

  {
  return_address = (void *)stackguard_get_ra();
  stackguard_push(return_address);
#line 3
  scanf("%s", array);
  {
  return_address = (void *)stackguard_pop();
  stackguard_set_ra(return_address);
#line 4
  return (0);
  }
}
}
#line 6 "cilcode.tmp/ex24.c"
int main(void) 
{ int tmp ;

  {
#line 7
  tmp = dangerous();
#line 7
  return (tmp);
}
}