author | Christian Urban <urbanc@in.tum.de> |
Mon, 06 Nov 2017 10:40:23 +0000 | |
changeset 561 | 17cd7fdee7c8 |
parent 211 | e6e160c7ea33 |
permissions | -rw-r--r-- |
203
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1 |
#include <string.h> |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2 |
#include <stdio.h> |
211
e6e160c7ea33
added files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
208
diff
changeset
|
3 |
//#include <stdlib.h> |
203
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
|
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
5 |
void foo (char *bar) |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
6 |
{ |
208
204564b899a0
progs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
205
diff
changeset
|
7 |
unsigned long my_long = 101010101; // in hex: \xB5\x4A\x05\x06 |
203
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
8 |
char buffer[28]; |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
9 |
|
208
204564b899a0
progs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
205
diff
changeset
|
10 |
printf("my_long value = %lu\n", my_long); |
203
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
11 |
|
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
12 |
strcpy(buffer, bar); |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
13 |
|
208
204564b899a0
progs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
205
diff
changeset
|
14 |
printf("my_long value = %lu\n", my_long); |
203
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
15 |
} |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
16 |
|
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
17 |
int main (int argc, char **argv) |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
18 |
{ |
205
88416b7df38c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
203
diff
changeset
|
19 |
foo("my string is too long !!!!!"); // all is normal |
88416b7df38c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
203
diff
changeset
|
20 |
foo("my string is too long !!!!! \x15\xcd\x5b\x07"); // overwrites my_long |
203
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
21 |
return 0; |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
22 |
} |
c75a03ab8ac9
test
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
23 |