Skip to content

code improvements#11

Open
PanosKostopoulos wants to merge 2 commits intocanonical:mainfrom
PanosKostopoulos:code_suggestions
Open

code improvements#11
PanosKostopoulos wants to merge 2 commits intocanonical:mainfrom
PanosKostopoulos:code_suggestions

Conversation

@PanosKostopoulos
Copy link
Copy Markdown

added checks for len_bytes value
changed allocation of memory to the appropriate value, as it always allocated max allowed memory.

Comment thread seccomp.c
{
if (len_bytes == 0){
die("len_bytes can not be 0");
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good use of validation to check len_bytes is not zero. This prevents division by zero and catches empty filter files.

Comment thread seccomp.c
}
if (len_bytes % sizeof(struct sock_filter) != 0){
die("filter length %u is not a multiple of instruction size %u", len_bytes, sizeof(struct sock_filter));
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The modulo operator % can be expensive. Consider using bitwise operations if sizeof(struct sock_filter) is a power of 2.

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.

2 participants