Exploit databaseDownload repository ZIP
GH-90ee35ea451d72b3be1eb23f54e9e44a
040840308-liu/icse2025-olasan-artifact
Sources for CVE-2016-10271
1 sourcePreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files194
040840308-liu/icse2025-olasan-artifactRevision d80e1423e6ba
- ↑..Parent directory
- CWE122_Heap_Based_Buffer_Overflow__placement_new_01.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_02.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_03.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_04.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_05.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_06.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_07.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_08.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_09.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_10.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_11.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_12.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_13.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_14.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_15.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_16.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_17.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_18.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_21.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_22a.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_22b.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_31.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_32.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_33.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_34.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_41.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_44.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_45.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_51a.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_51b.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_52a.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_52b.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_52c.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_53a.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_53b.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_53c.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_53d.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_54a.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_54b.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_54c.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_54d.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_54e.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_63a.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_63b.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_64a.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_64b.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_65a.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_65b.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_66a.cpp
- CWE122_Heap_Based_Buffer_Overflow__placement_new_66b.cpp
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
Juliet/testcases/CWE122_Heap_Based_Buffer_Overflow/s11/CWE122_Heap_Based_Buffer_Overflow__placement_new_22a.cpp
C++ · 4,438 bytes/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE122_Heap_Based_Buffer_Overflow__placement_new_22a.cpp
Label Definition File: CWE122_Heap_Based_Buffer_Overflow__placement_new.label.xml
Template File: sources-sinks-22a.tmpl.cpp
*/
/*
* @description
* CWE: 122 Heap Based Buffer Overflow
* BadSource: Initialize data to a small buffer
* GoodSource: Initialize data to a buffer large enough to hold a TwoIntsClass
* Sinks:
* GoodSink: Allocate a new class using placement new and a buffer that is large enough to hold the class
* BadSink : Allocate a new class using placement new and a buffer that is too small
* Flow Variant: 22 Control flow: Flow controlled by value of a global variable. Sink functions are in a separate file from sources.
*
* */
#include "std_testcase.h"
namespace CWE122_Heap_Based_Buffer_Overflow__placement_new_22
{
#ifndef OMITBAD
/* The global variable below is used to drive control flow in the sink function. Since it is in
a C++ namespace, it doesn't need a globally unique name. */
int badGlobal = 0;
void badSink(char * data);
void bad()
{
char * data;
char * dataBadBuffer = (char *)malloc(sizeof(OneIntClass));
if (dataBadBuffer == NULL) {exit(-1);}
char * dataGoodBuffer = (char *)malloc(sizeof(TwoIntsClass));
if (dataGoodBuffer == NULL) {exit(-1);}
/* POTENTIAL FLAW: Initialize data to a buffer small than the sizeof(TwoIntsClass) */
data = dataBadBuffer;
badGlobal = 1; /* true */
badSink(data);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* The global variables below are used to drive control flow in the sink functions. Since they are in
a C++ namespace, they don't need globally unique names. */
int goodB2G1Global = 0;
int goodB2G2Global = 0;
int goodG2B1Global = 0;
/* goodB2G1() - use badsource and goodsink by setting the static variable to false instead of true */
void goodB2G1Sink(char * data);
static void goodB2G1()
{
char * data;
char * dataBadBuffer = (char *)malloc(sizeof(OneIntClass));
if (dataBadBuffer == NULL) {exit(-1);}
char * dataGoodBuffer = (char *)malloc(sizeof(TwoIntsClass));
if (dataGoodBuffer == NULL) {exit(-1);}
/* POTENTIAL FLAW: Initialize data to a buffer small than the sizeof(TwoIntsClass) */
data = dataBadBuffer;
goodB2G1Global = 0; /* false */
goodB2G1Sink(data);
}
/* goodB2G2() - use badsource and goodsink by reversing the blocks in the if in the sink function */
void goodB2G2Sink(char * data);
static void goodB2G2()
{
char * data;
char * dataBadBuffer = (char *)malloc(sizeof(OneIntClass));
if (dataBadBuffer == NULL) {exit(-1);}
char * dataGoodBuffer = (char *)malloc(sizeof(TwoIntsClass));
if (dataGoodBuffer == NULL) {exit(-1);}
/* POTENTIAL FLAW: Initialize data to a buffer small than the sizeof(TwoIntsClass) */
data = dataBadBuffer;
goodB2G2Global = 1; /* true */
goodB2G2Sink(data);
}
/* goodG2B1() - use goodsource and badsink */
void goodG2B1Sink(char * data);
static void goodG2B1()
{
char * data;
char * dataBadBuffer = (char *)malloc(sizeof(OneIntClass));
if (dataBadBuffer == NULL) {exit(-1);}
char * dataGoodBuffer = (char *)malloc(sizeof(TwoIntsClass));
if (dataGoodBuffer == NULL) {exit(-1);}
/* FIX: Initialize to a buffer at least the sizeof(TwoIntsClass) */
data = dataGoodBuffer;
goodG2B1Global = 1; /* true */
goodG2B1Sink(data);
}
void good()
{
goodB2G1();
goodB2G2();
goodG2B1();
}
#endif /* OMITGOOD */
} /* close namespace */
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
using namespace CWE122_Heap_Based_Buffer_Overflow__placement_new_22; /* so that we can use good and bad easily */
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif