Skip to content
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

fix(dracut-install): file created without restricting permissions #2231

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 4 additions & 2 deletions src/install/dracut-install.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,9 +682,11 @@ void mark_hostonly(const char *path)

_asprintf(&fulldstpath, "%s/lib/dracut/hostonly-files", destrootdir);

f = fopen(fulldstpath, "a");
int fd = open(fulldstpath, O_RDONLY | O_APPEND, 0600);

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This argument to a file access function is derived from [user input (an environment variable)](1) and then passed to open(__path).
if (fd != -1)
f = fdopen(fd, "a");

if (f == NULL) {
if (fd == -1 || f == NULL) {
log_error("Could not open '%s' for writing.", fulldstpath);
return;
}
Expand Down