Skip to content

pfc: propagate buffered output errors - #495

Open
1234binpig wants to merge 1 commit into
seccomp:mainfrom
1234binpig:fix-pfc-output-errors
Open

pfc: propagate buffered output errors#495
1234binpig wants to merge 1 commit into
seccomp:mainfrom
1234binpig:fix-pfc-output-errors

Conversation

@1234binpig

Copy link
Copy Markdown

Problem

gen_pfc_generate() ignored errors reported by fflush() and fclose().

Because stdio output is buffered, write failures can first be reported while flushing or closing the stream. In that case, seccomp_export_pfc() could report success even though the generated output was not fully written.

Fix

Propagate buffered output errors while still closing the stream exactly once. If both operations fail, preserve the first reported output error.

Testing

Added a regression test using /dev/full.

Verified that:

  • the new regression test fails with the original implementation;
  • the regression test passes with this change.

gen_pfc_generate() ignored errors reported by fflush() and fclose(),
causing seccomp_export_pfc() to report success even when buffered
output could not be written.

Preserve the first output error while still closing the stream, and
add a regression test using /dev/full.

Signed-off-by: huangwenbin <huangwenbin@kylinos.cn>
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