Skip to content

Commit

Permalink
Fix out of bounds read in slarrv
Browse files Browse the repository at this point in the history
This was originally reported as JuliaLang/julia#42415.
I've tracked this down to an our of bounds read on the following line:

https://github.com/Reference-LAPACK/lapack/blob/44ecb6a5ff821b1cbb39f8cc2166cb098e060b4d/SRC/slarrv.f#L423

In the crashing example, `M` is `0`, causing `slarrv` to read uninitialized
memory from the work array. I believe the `0` for `M` is correct and indeed,
the documentation above supports that `M` may be zero:

https://github.com/Reference-LAPACK/lapack/blob/44ecb6a5ff821b1cbb39f8cc2166cb098e060b4d/SRC/slarrv.f#L113-L116

I believe it may be sufficient to early-out this function as suggested
in this PR. However, I have limited context for the full routine here,
so I would appreciate a sanity check.
  • Loading branch information
Keno committed Sep 30, 2021
1 parent 44ecb6a commit 0631b6b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion SRC/clarrv.f
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ SUBROUTINE CLARRV( N, VL, VU, D, L, PIVMIN,
*
* Quick return if possible
*
IF( N.LE.0 ) THEN
IF( (N.LE.0).OR.(M.LE.0) ) THEN
RETURN
END IF
*
Expand Down
2 changes: 1 addition & 1 deletion SRC/dlarrv.f
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ SUBROUTINE DLARRV( N, VL, VU, D, L, PIVMIN,
*
* Quick return if possible
*
IF( N.LE.0 ) THEN
IF( (N.LE.0).OR.(M.LE.0) ) THEN
RETURN
END IF
*
Expand Down
2 changes: 1 addition & 1 deletion SRC/slarrv.f
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ SUBROUTINE SLARRV( N, VL, VU, D, L, PIVMIN,
*
* Quick return if possible
*
IF( N.LE.0 ) THEN
IF( (N.LE.0).OR.(M.LE.0) ) THEN
RETURN
END IF
*
Expand Down
2 changes: 1 addition & 1 deletion SRC/zlarrv.f
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ SUBROUTINE ZLARRV( N, VL, VU, D, L, PIVMIN,
*
* Quick return if possible
*
IF( N.LE.0 ) THEN
IF( (N.LE.0).OR.(M.LE.0) ) THEN
RETURN
END IF
*
Expand Down

0 comments on commit 0631b6b

Please sign in to comment.