Commit ef3f7cc41280e9611a837df1fedf3f6d4d921a75

Authored by Roel Kluin
Committed by Linus Torvalds
1 parent 13bcbc0087

osst: fix read buffer overflow

Check whether index is within bounds before testing the element.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Cc: Willem Riede <osst@riede.org>
Cc: James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 2 additions and 1 deletions Side-by-side Diff

... ... @@ -5868,7 +5868,8 @@
5868 5868 }
5869 5869  
5870 5870 /* find a free minor number */
5871   - for (i=0; os_scsi_tapes[i] && i<osst_max_dev; i++);
  5871 + for (i = 0; i < osst_max_dev && os_scsi_tapes[i]; i++)
  5872 + ;
5872 5873 if(i >= osst_max_dev) panic ("Scsi_devices corrupt (osst)");
5873 5874 dev_num = i;
5874 5875