Skip to content

gen_init_cpio.c: fix buffer allocation size #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 6.11/bbr3
Choose a base branch
from

Conversation

watan104
Copy link

@watan104 watan104 commented Jun 6, 2025

Fix potential buffer overflow by allocating space for null terminator in hardlink name buffer.

Fix potential buffer overflow by allocating space for null terminator
in hardlink name buffer.
@watan104
Copy link
Author

watan104 commented Jun 6, 2025

Here's the issue I found: malloc(strlen(line)) allocates space based on the input line length, but the code then parses and reformats that data into a different structure with null-terminated strings.
The original line gets transformed from:
file1 /path 0755 0 0 hardlink1 hardlink2
into:
file1\0hardlink1\0hardlink2\0
Depending on parsing, this reformatted data can exceed the originally allocated buffer size, leading to potential buffer overflow.
The +1 ensures we have adequate space for the null terminator and accounts for the data structure transformation during hardlink processing.
This addresses a potential security vulnerability in the initramfs generation tool.

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