-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsource.c
53 lines (43 loc) · 986 Bytes
/
source.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
#include <stdlib.h>
#include <string.h>
int language = 0;
void greetuser(char *str)
{
char buf[64];
switch (language)
{
case 0:
strcpy(buf, "Hello ");
break;
case 1:
strcpy(buf, "Hyvää päivää ");
break;
case 2:
strcpy(buf, "Goedemiddag! ");
break;
}
strcat(buf, str);
puts(buf);
}
// one line difference main+31 (extra use of eax) and what appears to be a memcpy
int main(int argc, char **argv)
{
char buf[76];
char *ret;
char truc[64];
if (argc != 3)
return 1;
memset(buf, 0, 76);
strncpy(buf, argv[1], 40);
strncpy(buf + 40, argv[2], 32);
ret = getenv("LANG");
if (ret != 0)
{
if (memcmp(ret, "fi", 2) == 0)
language = 1;
else if (memcmp(ret, "nl", 2) == 0)
language = 2;
}
/* memcpy(esp, buf, 76); This happens in the assembly, I assume because of an optimization */
greetuser(buf);
}