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

Backport:v0.8 Fix multiple file match bugs #727

Merged
merged 1 commit into from
Feb 28, 2023

Conversation

kevsecurity
Copy link
Contributor

@kevsecurity kevsecurity commented Feb 23, 2023

This commit fixes a number of file match bugs:

__filter_file_buf() was passing a length value of one less than the string length to cmpbytes() and as a result Equals and Prefix matches were testing one fewer bytes than required.

ASM_RCMP (used in rcmpbytes()) was decrementing the string indices before testing if they were <1. This resulted in one fewer bytes being tested than required.

ASM_RCMP50 comprisd of 2x ASM_RCMP20 and 1x ASM_RCMP5, totalling 45 iterations of ASM_RCMP, instead of 50.

__filter_file_buf() tested failed postfix matches with a forward string match. This resulted in files that started with the postfix, but didn't end with it, matching when they shouldn't.

cmpbytes() continued to loop to full number of iterations, even when the string length had been exhausted (inefficient).

Added descriptions to cmpbytes() and rcmpbytes() to aid in providing the correct parameters.

[Upstream commit: 906b4a6]

This commit fixes a number of file match bugs:

* __filter_file_buf() was passing a length value of one less than the
  string length to cmpbytes() and as a result Equals and Prefix matches
  were testing one fewer bytes than required.

* ASM_RCMP (used in rcmpbytes()) was decrementing the string indices
  before testing if they were <1. This resulted in one fewer bytes being
  tested than required.

* ASM_RCMP50 comprisd of 2x ASM_RCMP20 and 1x ASM_RCMP5, totalling 45
  iterations of ASM_RCMP, instead of 50.

* __filter_file_buf() tested failed postfix matches with a forward string
  match. This resulted in files that started with the postfix, but didn't
  end with it, matching when they shouldn't.

* cmpbytes() continued to loop to full number of iterations, even when
  the string length had been exhausted (inefficient).

* Added descriptions to cmpbytes() and rcmpbytes() to aid in providing
  the correct parameters.

Signed-off-by: Kevin Sheldrake <[email protected]>
@kevsecurity kevsecurity requested a review from a team as a code owner February 23, 2023 16:25
@kevsecurity kevsecurity requested review from jrfastab and removed request for a team February 23, 2023 16:25
@kkourt kkourt merged commit f0b12fa into v0.8 Feb 28, 2023
@kkourt kkourt deleted the backports/v0.8/kevsecurity/fix-selector-cmp branch February 28, 2023 10:06
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