Skip to content

Fix #847: missing range checks in statespace_*.h files #848

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mhucka
Copy link
Collaborator

@mhucka mhucka commented Jul 31, 2025

CodeQL scans flagged lines like 353 in lib/statespace_avx512.h, reporting that the use of offset m should follow the range check:

     while (rs[m] < csum && m < num_samples) {

In more detail:

The program contains an and-expression where the array access is defined before the range check. Consequently the array is accessed without any bounds checking. The range check does not protect the program from segmentation faults caused by attempts to read beyond the end of a buffer.

The same error exists in the following files:

  • statespace_basic.h
  • statespace_sse.h
  • statespace_avx512.h
  • statespace_avx.h

CodeQL scans flagged lines like 353 in `lib/statespace_avx512.h`, reporting that the use of offset `m` should follow the range check:

```C++
     while (rs[m] < csum && m < num_samples) {
```

In more detail:

> The program contains an and-expression where the array access is defined before the range check. Consequently the array is accessed without any bounds checking. The range check does not protect the program from segmentation faults caused by attempts to read beyond the end of a buffer.

The same error exists in the following files:

* statespace_basic.h
* statespace_sse.h
* statespace_avx512.h
* statespace_avx.h
@mhucka mhucka self-assigned this Jul 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant