Skip to content

Commit

Permalink
ALSA: hda - possible read past array alc88[02]_parse_auto_config()
Browse files Browse the repository at this point in the history
The test of index `i' is after the read - too late - and
unsafe: if snd_hda_get_connections() fails in the last
iteration a read beyond the array is possible.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Roel Kluin authored and Takashi Iwai committed Nov 11, 2009
1 parent 4ac5598 commit 71121d9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sound/pci/hda/patch_realtek.c
Original file line number Diff line number Diff line change
Expand Up @@ -4684,9 +4684,9 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
spec->multiout.dig_out_nid = dig_nid;
else {
spec->multiout.slave_dig_outs = spec->slave_dig_outs;
spec->slave_dig_outs[i - 1] = dig_nid;
if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
break;
spec->slave_dig_outs[i - 1] = dig_nid;
}
}
if (spec->autocfg.dig_in_pin)
Expand Down Expand Up @@ -9813,9 +9813,9 @@ static int alc882_parse_auto_config(struct hda_codec *codec)
spec->multiout.dig_out_nid = dig_nid;
else {
spec->multiout.slave_dig_outs = spec->slave_dig_outs;
spec->slave_dig_outs[i - 1] = dig_nid;
if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
break;
spec->slave_dig_outs[i - 1] = dig_nid;
}
}
if (spec->autocfg.dig_in_pin)
Expand Down

0 comments on commit 71121d9

Please sign in to comment.