Skip to content

Improvements - DevSkiller#17

Open
GitGudBruhh wants to merge 9 commits into
canonical:mainfrom
GitGudBruhh:main
Open

Improvements - DevSkiller#17
GitGudBruhh wants to merge 9 commits into
canonical:mainfrom
GitGudBruhh:main

Conversation

@GitGudBruhh

@GitGudBruhh GitGudBruhh commented May 31, 2026

Copy link
Copy Markdown
  • Merged changes from the original improve branch
    • Bugfixes and improvements made in the merged test files
  • Freed resources after use and before each die is called
  • Added .gitignore for built files
  • Added checks for supported seccomp file headers
  • Improvements in sc_must_read_filter_from_file()
    • len_bytes must now be an integer multiple of sizeof(struct sock_filter)
    • Added overflow checks when assigning to prog->len (type unsigned short)
  • Fixed seccomp.h header guard

@abouhasna abouhasna left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Overall, this is a solid improvement over the original code, good catches on the overflow and alignment checks. There are just a few things I noticed which you can find in the comments.

Comment thread seccomp.c
Comment thread main.c

sc_apply_seccomp_filter(&prog_allow);
free(prog_allow.filter);
fclose(file);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If the file was already closed in previous functions, this may lead to undefined behavior

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

file is only closed in previous functions when die() is called and the program exits. The control flow reaching here guarantees file to be open.

Comment thread unit-tests/unit-tests.c
struct sc_seccomp_file_header hdr = {};

if (g_test_subprocess()) {
char *profile = NULL;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

profile is never freed

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Resolved in ca73c34 for the happy test. The missing_header test does not have a free() for profile as the program dies during the test.

Comment thread unit-tests/unit-tests.c
char *profile = NULL;
int fd = 0;
make_seccomp_profile(&hdr, &fd, &profile);
FILE *file = sc_must_read_and_validate_header_from_file(profile, &hdr);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

file is never closed

@GitGudBruhh GitGudBruhh Jun 10, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Resolved in ca73c34 for the happy test. The missing_header test does not have a fclose() for file as the program dies during the test.

Comment thread unit-tests/unit-tests.c Outdated
Comment thread main.c Outdated
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