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__sizeof_struct_08.c
C · 3,834 bytes/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE122_Heap_Based_Buffer_Overflow__sizeof_struct_08.c
Label Definition File: CWE122_Heap_Based_Buffer_Overflow__sizeof.label.xml
Template File: sources-sink-08.tmpl.c
*/
/*
* @description
* CWE: 122 Heap Based Buffer Overflow
* BadSource: Initialize the source buffer using the size of a pointer
* GoodSource: Initialize the source buffer using the size of the DataElementType
* Sink:
* BadSink : Print then free data
* Flow Variant: 08 Control flow: if(staticReturnsTrue()) and if(staticReturnsFalse())
*
* */
#include "std_testcase.h"
/* The two function below always return the same value, so a tool
* should be able to identify that calls to the functions will always
* return a fixed value.
*/
static int staticReturnsTrue()
{
return 1;
}
static int staticReturnsFalse()
{
return 0;
}
#ifndef OMITBAD
void CWE122_Heap_Based_Buffer_Overflow__sizeof_struct_08_bad()
{
twoIntsStruct * data;
/* Initialize data */
data = NULL;
if(staticReturnsTrue())
{
/* INCIDENTAL: CWE-467 (Use of sizeof() on a pointer type) */
/* FLAW: Using sizeof the pointer and not the data type in malloc() */
data = (twoIntsStruct *)malloc(sizeof(data));
if (data == NULL) {exit(-1);}
data->intOne = 1;
data->intTwo = 2;
}
/* POTENTIAL FLAW: Attempt to use data, which may not have enough memory allocated */
printStructLine(data);
free(data);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B1() - use goodsource and badsink by changing the staticReturnsTrue() to staticReturnsFalse() */
static void goodG2B1()
{
twoIntsStruct * data;
/* Initialize data */
data = NULL;
if(staticReturnsFalse())
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
}
else
{
/* FIX: Using sizeof the data type in malloc() */
data = (twoIntsStruct *)malloc(sizeof(*data));
if (data == NULL) {exit(-1);}
data->intOne = 1;
data->intTwo = 2;
}
/* POTENTIAL FLAW: Attempt to use data, which may not have enough memory allocated */
printStructLine(data);
free(data);
}
/* goodG2B2() - use goodsource and badsink by reversing the blocks in the if statement */
static void goodG2B2()
{
twoIntsStruct * data;
/* Initialize data */
data = NULL;
if(staticReturnsTrue())
{
/* FIX: Using sizeof the data type in malloc() */
data = (twoIntsStruct *)malloc(sizeof(*data));
if (data == NULL) {exit(-1);}
data->intOne = 1;
data->intTwo = 2;
}
/* POTENTIAL FLAW: Attempt to use data, which may not have enough memory allocated */
printStructLine(data);
free(data);
}
void CWE122_Heap_Based_Buffer_Overflow__sizeof_struct_08_good()
{
goodG2B1();
goodG2B2();
}
#endif /* OMITGOOD */
/* 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
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE122_Heap_Based_Buffer_Overflow__sizeof_struct_08_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE122_Heap_Based_Buffer_Overflow__sizeof_struct_08_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif