I'm trying to create a buffer overflow with C# for a school project:
unsafe { fixed (char* ptr_str = new char[6] {'H', 'a', 'l', 'l', 'o', ','}) { fixed (char* ptr_str2 = new char[6] {'W', 'e', 'r', 'e', 'l', 'd'}) { fixed (char* ptr_str3 = new char[6] {'!', '!', '!', '!', '!', '!'}) { for (int i = 0; i < 8; i++) { ptr_str2[i] = 'a'; } for (int i = 0; i < 6; i++) { this.Label2.Text += ptr_str[i]; this.Label3.Text += ptr_str2[i]; this.Label4.Text += ptr_str3[i]; } } } } } I thought this would flood ptr_str2 and thereby overwriting chars in ptr_str. However that does not seem to happen. It does execute but the values in ptr_str are not overwritten.
Can anyone help with achieving this? I don't understand what I'm doing wrong.