-
Notifications
You must be signed in to change notification settings - Fork 0
/
chall.c
60 lines (48 loc) · 1.34 KB
/
chall.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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BUF_LEN 128
struct Report {
char message[BUF_LEN];
char details[BUF_LEN];
};
void camelCase(char *message) {
while (*message) {
if (*message == ' ') {
message++;
putchar(*message & 0xDF);
} else {
putchar(*message);
}
message++;
}
puts("");
}
// This function isn't needed for solving the chal. You can skip this function.
void buffering() {
setvbuf(stdin, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
setvbuf(stdout, NULL, _IONBF, 0);
}
void fillReportDetails(struct Report *report) {
strncpy(report->details, getenv("FLAG"), BUF_LEN);
}
int main(int argc, char **argv) {
struct Report report;
buffering();
// The application crashed: fill the details of the report.
fillReportDetails(&report);
puts("!! -- Ops, it looks like the application has encountered a problem -- "
"!! ");
puts("# Contact the administrator and report the problem.");
puts("Before sending it we will format your message.");
puts("\t-> Remember that the whitespaces disappear.");
puts("\t-> The first letter will be replaced with the uppercase");
printf("Enter your message: ");
fgets(report.message, BUF_LEN, stdin);
puts("");
puts("===> Report sent!");
puts("Your report-> ");
camelCase(report.message);
return 0;
}