Skip to content

Commit 0631b6b

Browse files
committed
Fix out of bounds read in slarrv
This was originally reported as https://github.com/JuliaLang/julia/issues/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.
1 parent 44ecb6a commit 0631b6b

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

SRC/clarrv.f

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ SUBROUTINE CLARRV( N, VL, VU, D, L, PIVMIN,
348348
*
349349
* Quick return if possible
350350
*
351-
IF( N.LE.0 ) THEN
351+
IF( (N.LE.0).OR.(M.LE.0) ) THEN
352352
RETURN
353353
END IF
354354
*

SRC/dlarrv.f

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ SUBROUTINE DLARRV( N, VL, VU, D, L, PIVMIN,
350350
*
351351
* Quick return if possible
352352
*
353-
IF( N.LE.0 ) THEN
353+
IF( (N.LE.0).OR.(M.LE.0) ) THEN
354354
RETURN
355355
END IF
356356
*

SRC/slarrv.f

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ SUBROUTINE SLARRV( N, VL, VU, D, L, PIVMIN,
350350
*
351351
* Quick return if possible
352352
*
353-
IF( N.LE.0 ) THEN
353+
IF( (N.LE.0).OR.(M.LE.0) ) THEN
354354
RETURN
355355
END IF
356356
*

SRC/zlarrv.f

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ SUBROUTINE ZLARRV( N, VL, VU, D, L, PIVMIN,
348348
*
349349
* Quick return if possible
350350
*
351-
IF( N.LE.0 ) THEN
351+
IF( (N.LE.0).OR.(M.LE.0) ) THEN
352352
RETURN
353353
END IF
354354
*

0 commit comments

Comments
 (0)