forked from google/sandboxed-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sum.c
97 lines (80 loc) · 1.84 KB
/
sum.c
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Copyright 2019 Google LLC. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/ptrace.h>
int sumsymbol = 5;
typedef struct sum_params_s {
int a;
int b;
int ret;
} sum_params;
extern int ftest(FILE *f) {
return f->_offset;
}
extern int sum(int a, int b) {
return a + b;
}
extern void sums(sum_params* params) {
params->ret = params->a + params->b;
}
extern long double addf(float a, double b, long double c) {
return a + b + c;
}
extern int sub(int a, int b) {
return a - b;
}
extern int mul(int a, int b) {
return a * b;
}
extern int divs(int a, int b) {
return a / b;
}
extern double muld(double a, float b) {
return a * b;
}
extern void crash(void) {
void(*die)() = (void(*)())(0x0000dead);
die();
}
extern void violate(void) {
ptrace(990, 991, 992, 993);
}
extern int sumarr(int* input, size_t nelem) {
int s = 0, i;
for (i = 0; i < nelem; i++) {
s += input[i];
}
return s;
}
extern void testptr(void *ptr) {
if (ptr) {
puts("Is Not a NULL-ptr");
} else {
puts("Is a NULL-ptr");
}
}
extern int read_int(int fd) {
char buf[10] = {0};
int ret = read(fd, buf, sizeof(buf) - 1);
if(ret > 0) {
ret = atoi(buf);
}
return ret;
}
extern void sleep_for_sec(int sec) {
sleep(sec);
}