Skip to content

Commit

Permalink
ALSA: isa/wavefront: prevent some out of bound writes
Browse files Browse the repository at this point in the history
"header->number" can be up to USHRT_MAX and it comes from the ioctl so
it needs to be capped.

Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
Dan Carpenter authored and tiwai committed May 8, 2016
1 parent e4ec8cc commit 84d7a44
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions sound/isa/wavefront/wavefront_synth.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,9 @@ wavefront_send_patch (snd_wavefront_t *dev, wavefront_patch_info *header)
DPRINT (WF_DEBUG_LOAD_PATCH, "downloading patch %d\n",
header->number);

if (header->number >= ARRAY_SIZE(dev->patch_status))
return -EINVAL;

dev->patch_status[header->number] |= WF_SLOT_FILLED;

bptr = buf;
Expand All @@ -809,6 +812,9 @@ wavefront_send_program (snd_wavefront_t *dev, wavefront_patch_info *header)
DPRINT (WF_DEBUG_LOAD_PATCH, "downloading program %d\n",
header->number);

if (header->number >= ARRAY_SIZE(dev->prog_status))
return -EINVAL;

dev->prog_status[header->number] = WF_SLOT_USED;

/* XXX need to zero existing SLOT_USED bit for program_status[i]
Expand Down Expand Up @@ -898,6 +904,9 @@ wavefront_send_sample (snd_wavefront_t *dev,
header->number = x;
}

if (header->number >= WF_MAX_SAMPLE)
return -EINVAL;

if (header->size) {

/* XXX it's a debatable point whether or not RDONLY semantics
Expand Down

0 comments on commit 84d7a44

Please sign in to comment.