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 02d4a9d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions SRC/slarrv.f
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,13 @@ SUBROUTINE SLARRV( N, VL, VU, D, L, PIVMIN,
CALL SLASET( 'Full', N, ZUSEDW, ZERO, ZERO,
$ Z(1,ZUSEDL), LDZ )

*
* Early exit if we have no eigenvalues
*
IF( M.LE.0 ) THEN
RETURN
END IF

EPS = SLAMCH( 'Precision' )
RQTOL = TWO * EPS
*
Expand Down

0 comments on commit 02d4a9d

Please sign in to comment.