Created
March 16, 2019 11:44
-
-
Save Bloofer/ae1cfe708cc50905fc89011e8945c17d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <stdio.h> | |
void foo (char *bar) | |
{ | |
float My_Float = 10.5; // Addr = 0x0023FF4C | |
char c[28]; // Addr = 0x0023FF30 | |
// Will print 10.500000 | |
printf("My Float value = %f\n", My_Float); | |
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
Memory map: | |
@ : c allocated memory | |
# : My_Float allocated memory | |
*c *My_Float | |
0x0023FF30 0x0023FF4C | |
| | | |
@@@@@@@@@@@@@@@@@@@@@@@@@@@@##### | |
foo("my string is too long !!!!! XXXXX"); | |
memcpy will put 0x1010C042 (little endian) in My_Float value. | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ | |
memcpy(c, bar, strlen(bar)); // no bounds checking... | |
// Will print 96.031372 | |
printf("My Float value = %f\n", My_Float); | |
} | |
int main (int argc, char **argv) | |
{ | |
foo("my string is too long !!!!! \x10\x10\xc0\x42"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment