forked from Billy-Ellis/Exploit-Challenges
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathint_overflow.c
More file actions
43 lines (34 loc) · 830 Bytes
/
Copy pathint_overflow.c
File metadata and controls
43 lines (34 loc) · 830 Bytes
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
//
// int_overflow.c
//
//
// Created by Billy Ellis on 13/03/2018.
//
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
unsigned int get_length(char data[]){
unsigned int size;
for (size = 0; data[size] != '\0'; size++);
return size;
}
void buffer_the_data(char data[]){
char dataBuf[32];
//copy data into dataBuf[]
strcpy(dataBuf,data);
printf("Data is %s\n",dataBuf);
}
int main(int argc, char *argv[]){
if (argc < 2){
printf("Usage: %s <DATA>\n",argv[0]);
exit(-1);
}
unsigned char dataLen = get_length(argv[1]);
if (dataLen < 32){
printf("Data is valid!\n");
buffer_the_data(argv[1]);
}else{
printf("The data you entered is too large. Data must be less than 32 bytes.\n");
}
return 0;
}