/** * @Comment: WSU - Fall 06 - CS 3830-0 * @Title: prj2c.c - Project 2c * @Author: Vincenzo Maggio */ #include #include #include #include int main( int argc, char *argv[]) { int i; char *entree, *veggie, *dessert, *meal; entree = (char*) malloc( strlen( argv[1])); veggie = (char*) malloc( strlen( argv[2])); dessert = (char*) malloc( strlen( argv[3])); meal = (char*) malloc( (size_t) 15 ); if ( entree == NULL || veggie == NULL || dessert == NULL || meal == NULL ) { printf("\nError: malloc() failed. Aborting..\n\n"); return -1; } memset( meal, '\0', 15); system("cls"); system("color 1e"); gotoxy( 27, 2); puts("--==]~~~ \01 0xYg3N \01 ~~~[==--"); gotoxy( 2, 4); puts("Heap Overflow - Meal is [14+1] long"); gotoxy( 1, 6); puts( "Address 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF"); gotoxy( 1, 8); printf( "%x ", meal); gotoxy( 9, 8); for ( i=0; i<16; i++) printf( "%2x ", *(meal+i)); gotoxy( 64, 8); for ( i=0; i<16; i++) printf( "%c", *(meal+i)); strcat( meal, entree); strcat( meal, " + "); strcat( meal, veggie); strcat( meal, " + "); strcat( meal, dessert); gotoxy( 1, 10); printf( "%x ", meal); gotoxy( 10, 10); for ( i=0; i<16; i++) printf( "%2x ", *(meal+i)); gotoxy( 64, 10); for ( i=0; i<16; i++) printf( "%c", *(meal+i)); printf("\n\n "); system("pause"); system("color 0f"); printf("\n\n Thanks for using Prj2c!\n\n"); return 0; }