From a282420a4938879fe1f09717fdbf2bfff105370d Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Fri, 4 Nov 2016 09:18:04 +0100 Subject: [PATCH] In OSS/FreeBSD sio_setpar(), validate the encoding, ensuring we never end-up with an unknown one. --- libsndio/sio_oss.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libsndio/sio_oss.c b/libsndio/sio_oss.c index a348797..2c96622 100644 --- a/libsndio/sio_oss.c +++ b/libsndio/sio_oss.c @@ -415,6 +415,16 @@ sio_oss_setpar(struct sio_hdl *sh, struct sio_par *par) return 0; } + for (i = 0; ; i++) { + if (i == sizeof(formats) / sizeof(formats[0])) { + DPRINTF("sio_oss_setpar: unknown fmt %d\n", hdl->fmt); + hdl->sio.eof = 1; + return 0; + } + if (formats[i].fmt == hdl->fmt) + break; + } + if (ioctl(hdl->fd, SNDCTL_DSP_SPEED, &hdl->rate) < 0) { DPERROR("sio_oss_setpar: SPEED"); hdl->sio.eof = 1;