Skip to content

Fix Buffer Overflow in mke2fs test_disk Function#239

Open
PwnVerse wants to merge 1 commit into
tytso:masterfrom
PwnVerse:patch-1
Open

Fix Buffer Overflow in mke2fs test_disk Function#239
PwnVerse wants to merge 1 commit into
tytso:masterfrom
PwnVerse:patch-1

Conversation

@PwnVerse
Copy link
Copy Markdown

@PwnVerse PwnVerse commented Sep 1, 2025

Summary

Fix critical buffer overflow vulnerability in test_disk() function where unbounded sprintf() can write beyond the 1024-byte buffer when processing long device names.

Description

The sprintf() call at line 258 in mke2fs.c constructs a command string without bounds checking:

char buf[1024];
sprintf(buf, "badblocks -b %d -X %s%s%s %llu", fs->blocksize,
    quiet ? "" : "-s ", (cflag > 1) ? "-w " : "",
    fs->device_name,
    (unsigned long long) ext2fs_blocks_count(fs->super)-1);

Potential for stack-based buffer overflow with device names > ~950 characters.

Patch

Replace sprintf() with snprintf() for bounds checking and add proper error handling for oversized command strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant