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

Fix two out of bounds accesses from #13330. #13525

Merged
merged 1 commit into from
Jul 12, 2021

Conversation

firetech
Copy link
Contributor

Description

Two occurrences of MATRIX_ROWS weren't properly changed to ROWS_PER_HAND in #13330, causing a crash during boot on at least my Ergodox Infinity (including #13481).

(Only the matrix_init_pins() one, for ROW2COL, caused the crash on my Ergodox Infinity, but I found both these differences by comparing quantum/matrix.c after the change and quantum/split_common/matrix.c before the change, so both changes should be correct.)

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

Two occurrences of `MATRIX_ROWS` weren't properly changed to
`ROWS_PER_HAND` in qmk#13330, causing a crash during boot on at least my
Ergodox Infinity (including qmk#13481).
@KarlK90
Copy link
Member

KarlK90 commented Jul 12, 2021

Good catch! I'm wondering if row_pins should have its size determined by ROWS_PER_HAND as well? For non-splits the capacity stays the same aka. MATRIX_ROWS and for splits the maximum capacity is halved. The loops certainly wont read/write past it now.

@firetech
Copy link
Contributor Author

Good catch! I'm wondering if row_pins should have its size determined by ROWS_PER_HAND as well? For non-splits the capacity stays the same aka. MATRIX_ROWS and for splits the maximum capacity is halved. The loops certainly wont read/write past it now.

It seems to be a bit of a mess... The declaration was row_pins[MATRIX_ROWS] in the old split_common/matrix.c as well. Both the handling of DIRECT_PINS and and the MATRIX_ROW_PINS_RIGHT handling later in the file are also using the full MATRIX_ROWS in their loops, which is probably not correct either, but I'm not sure enough to dare to change it. 😛

This was the only related differences I found compared to the old split_common/matrix.c file.

@drashna drashna requested a review from a team July 12, 2021 15:34
@drashna drashna merged commit 4706231 into qmk:develop Jul 12, 2021
@drashna
Copy link
Member

drashna commented Jul 12, 2021

Nice catch!

@firetech firetech deleted the fix_split_matrix_oob branch July 12, 2021 15:47
@drashna
Copy link
Member

drashna commented Jul 12, 2021

And for what it's worth, I did test this on a couple of boards of mine, without issue. But AVR, so ... that may be a factor.

nhongooi pushed a commit to nhongooi/qmk_firmware that referenced this pull request Dec 5, 2021
Two occurrences of `MATRIX_ROWS` weren't properly changed to
`ROWS_PER_HAND` in qmk#13330, causing a crash during boot on at least my
Ergodox Infinity (including qmk#13481).
BorisTestov pushed a commit to BorisTestov/qmk_firmware that referenced this pull request May 23, 2024
Two occurrences of `MATRIX_ROWS` weren't properly changed to
`ROWS_PER_HAND` in qmk#13330, causing a crash during boot on at least my
Ergodox Infinity (including qmk#13481).
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.

4 participants