Ich versuche, einen Pufferüberlauf für ein Beispiel für die Schule in C++ zu erstellenC++

Programme in C++. Entwicklerforum
Anonymous
 Ich versuche, einen Pufferüberlauf für ein Beispiel für die Schule in C++ zu erstellen

Post by Anonymous »

Ich versuche, die Grundlagen eines Pufferüberlaufs zu realisieren, überhaupt nichts Illegales. Nach meinem Verständnis des folgenden Codes bietet der überlaufende Puffer nicht genügend Platz für alle zu schreibenden Daten, was bedeutet, dass er sie in p1 schreibt (

Code: Select all

p1
start ist 32 Bit? weg vom Ende des Überlaufs). Ich kann es jedoch nicht zum Laufen bringen und weiß nicht warum.

Code: Select all

#include 
#include 
#include 
#include 

int main() {

//create two pieces of stack memory - p1 first and then overflowing below it,
//so that overflow can overflow into p1
char* p1 = (char*)malloc(32 * sizeof(char));
char* overflowing = (char*)malloc(32 * sizeof(char));

//get the end location of p1
auto temp = p1;
for (int i = 0; i < 32; i++) { temp++; }

//see the memory locations of p1, end of p1, and overflow memory start
std::cout

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post