Skip to content

Backport 2407 - #2438

Merged
jan-cerny merged 1 commit into
OpenSCAP:maint-1.3from
Mab879:2407_maint_1_3
Oct 7, 2026
Merged

jan-cerny merged 1 commit into
OpenSCAP:maint-1.3from
Mab879:2407_maint_1_3

Conversation

@Mab879

@Mab879 Mab879 commented Oct 5, 2026

Copy link
Copy Markdown
Member

This isn't a straight backport some adjustments had to be made to due to merge conflicts.

Backport #2407

@Mab879 Mab879 added this to the 1.3.15 milestone Oct 5, 2026
} else {
char *path_with_prefix = oscap_path_join(prefix, pbuf);
fd = open(path_with_prefix, O_RDONLY);
fd = open(path_with_prefix, O_RDONLY | O_NONBLOCK);
} else {
char *path_with_prefix = oscap_path_join(prefix, pbuf);
fd = open(path_with_prefix, O_RDONLY);
fd = open(path_with_prefix, O_RDONLY | O_NONBLOCK);
NULL);
probe_item_add_msg(itm, OVAL_MESSAGE_LEVEL_ERROR,
"File \"%s\" status can't be read: errno=%d, %s.",
pbuf, errno, strerror(errno));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The errno is only reliable right after the fstat fails. The probe_item_create and probe_item_add_msg can modify the errno value, which can cause that the strerror(errno) will produce a wrong/misleading message. The original PR calls oscap_strerror_r right after the fstat fails to prevent the message being broken by later errno changes. We need a similar solution here. The function oscap_strerror_r is available in maint-1.3 so I think it can be used as in the original PR.

Comment thread src/OVAL/probes/independent/filehash58_probe.c Fixed
"hash_type",OVAL_DATATYPE_STRING, h,
NULL);
probe_item_add_msg(itm, OVAL_MESSAGE_LEVEL_ERROR,
"File \"%s\" status can't be read0:, %s.",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the stray zero

Suggested change
"File \"%s\" status can't be read0:, %s.",
"File \"%s\" status can't be read:, %s.",

);
probe_item_add_msg(itm, OVAL_MESSAGE_LEVEL_ERROR,
"File \"%s\" status can't be read: errno=%d, %s.",
pbuf, errno, strerror(errno));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file also suffers from the problem with errno that I mentioned yesterday.

@jan-cerny jan-cerny self-assigned this Oct 6, 2026
The filehash and filehash58 probes call `open(pbuf, O_RDONLY)` without
checking the file type. If the target is a FIFO (named pipe), `open()`
blocks indefinitely waiting for a writer. The user simply runs `mkfifo
~/somefile` — when the compliance scan traverses their home directory,
the entire oscap process hangs.

Additionally, a symlink to `/dev/zero` causes an infinite read loop
in `crapi_mdigest_fd()`.

Both problems will be avoided by checking whether the file isn't
blocking and is a regular file. The function `crapi_mdigest_fd`
isn't modified by the commit but the issue is avoided because
the function is guarded by the checks.

This is a adjusted backport of OpenSCAP#2407

Co-Authored-By: Jan Černý <jcerny@redhat.com>
Co-Authored-By: opencode <noreply@opencode.ai>
@sonarqubecloud

sonarqubecloud Bot commented Oct 6, 2026

Copy link
Copy Markdown

@jan-cerny jan-cerny left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have confirmed that the PR correctly backports the linked PR to the target branch.

@jan-cerny
jan-cerny merged commit e8cf074 into OpenSCAP:maint-1.3 Oct 7, 2026
10 of 11 checks passed
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.

3 participants