CVS commit: src/sys/compat/ossaudio
Module Name:src Committed By: nia Date: Sun Apr 19 21:37:00 UTC 2020 Modified Files: src/sys/compat/ossaudio: ossaudio.c Log Message: ossaudio: Avoid giving userland uninitialized memory. Noticed by maxv. The uninitalized field in this structure is `fillers`, an array that simply reserves space for later changes in OSSv4, which this version of the OSS compat layer (specifically for Linux applications) makes no effort to implement. To generate a diff of this commit: cvs rdiff -u -r1.82 -r1.83 src/sys/compat/ossaudio/ossaudio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/ossaudio/ossaudio.c diff -u src/sys/compat/ossaudio/ossaudio.c:1.82 src/sys/compat/ossaudio/ossaudio.c:1.83 --- src/sys/compat/ossaudio/ossaudio.c:1.82 Sun Apr 19 13:44:51 2020 +++ src/sys/compat/ossaudio/ossaudio.c Sun Apr 19 21:37:00 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ossaudio.c,v 1.82 2020/04/19 13:44:51 nia Exp $ */ +/* $NetBSD: ossaudio.c,v 1.83 2020/04/19 21:37:00 nia Exp $ */ /*- * Copyright (c) 1997, 2008 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.82 2020/04/19 13:44:51 nia Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.83 2020/04/19 21:37:00 nia Exp $"); #include #include @@ -1103,6 +1103,7 @@ oss_ioctl_mixer(struct lwp *lwp, const s __func__, error)); goto out; } + memset(, 0, sizeof omi); omi.modify_counter = 1; strncpy(omi.id, adev.name, sizeof omi.id); strncpy(omi.name, adev.name, sizeof omi.name);
CVS commit: src/sys/compat/ossaudio
Module Name:src Committed By: isaki Date: Sat Feb 2 05:02:03 UTC 2019 Modified Files: src/sys/compat/ossaudio: ossaudio.c Log Message: Correct debug messages. To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/sys/compat/ossaudio/ossaudio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/ossaudio/ossaudio.c diff -u src/sys/compat/ossaudio/ossaudio.c:1.72 src/sys/compat/ossaudio/ossaudio.c:1.73 --- src/sys/compat/ossaudio/ossaudio.c:1.72 Sat Feb 2 04:52:16 2019 +++ src/sys/compat/ossaudio/ossaudio.c Sat Feb 2 05:02:03 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ossaudio.c,v 1.72 2019/02/02 04:52:16 isaki Exp $ */ +/* $NetBSD: ossaudio.c,v 1.73 2019/02/02 05:02:03 isaki Exp $ */ /*- * Copyright (c) 1997, 2008 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.72 2019/02/02 04:52:16 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.73 2019/02/02 05:02:03 isaki Exp $"); #include #include @@ -509,12 +509,12 @@ oss_ioctl_audio(struct lwp *l, const str AUDIO_INITINFO(); error = copyin(SCARG(uap, data), , sizeof idat); if (error) { - DPRINTF(("%s: DSP_SETFRAGMENT %d\n", + DPRINTF(("%s: SNDCTL_DSP_SETFRAGMENT %d\n", __func__, error)); goto out; } if ((idat & 0x) < 4 || (idat & 0x) > 17) { - DPRINTF(("%s: DSP_SETFRAGMENT bad ival%d\n", + DPRINTF(("%s: SNDCTL_DSP_SETFRAGMENT bad ival%d\n", __func__, idat)); error = EINVAL; goto out; @@ -657,7 +657,7 @@ oss_ioctl_audio(struct lwp *l, const str idat = 1; error = ioctlf(fp, FIONBIO, ); if (error) { - DPRINTF(("%s: SENDCLT_DSP_NONBLOCK %d\n", + DPRINTF(("%s: FIONBIO %d\n", __func__, error)); goto out; }
CVS commit: src/sys/compat/ossaudio
Module Name:src Committed By: isaki Date: Tue Jan 29 12:01:20 UTC 2019 Modified Files: src/sys/compat/ossaudio: ossaudio.c Log Message: Revert a wrong OSS_SNDCTL_DSP_GETOSPACE part of rev1.70. - 'fragments' is the number of full free blocks and should not be negative value. - 'bytes' should not be rounded down. To generate a diff of this commit: cvs rdiff -u -r1.70 -r1.71 src/sys/compat/ossaudio/ossaudio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/ossaudio/ossaudio.c diff -u src/sys/compat/ossaudio/ossaudio.c:1.70 src/sys/compat/ossaudio/ossaudio.c:1.71 --- src/sys/compat/ossaudio/ossaudio.c:1.70 Fri Mar 24 14:32:29 2017 +++ src/sys/compat/ossaudio/ossaudio.c Tue Jan 29 12:01:20 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ossaudio.c,v 1.70 2017/03/24 14:32:29 nat Exp $ */ +/* $NetBSD: ossaudio.c,v 1.71 2019/01/29 12:01:20 isaki Exp $ */ /*- * Copyright (c) 1997, 2008 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.70 2017/03/24 14:32:29 nat Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.71 2019/01/29 12:01:20 isaki Exp $"); #include #include @@ -619,11 +619,12 @@ oss_ioctl_audio(struct lwp *l, const str } setblocksize(fp, ); bufinfo.fragsize = tmpinfo.blocksize; - bufinfo.fragments = (tmpinfo.hiwat * tmpinfo.blocksize - - (tmpinfo.play.seek + tmpinfo.blocksize -1)) / + bufinfo.fragments = tmpinfo.hiwat - + (tmpinfo.play.seek + tmpinfo.blocksize - 1) / tmpinfo.blocksize; bufinfo.fragstotal = tmpinfo.hiwat; - bufinfo.bytes = bufinfo.fragments * tmpinfo.blocksize; + bufinfo.bytes = + tmpinfo.hiwat * tmpinfo.blocksize - tmpinfo.play.seek; error = copyout(, SCARG(uap, data), sizeof bufinfo); if (error) { DPRINTF(("%s: SNDCTL_DSP_GETOSPACE = %d\n",
CVS commit: src/sys/compat/ossaudio
Module Name:src Committed By: nat Date: Fri Mar 24 14:32:29 UTC 2017 Modified Files: src/sys/compat/ossaudio: ossaudio.c Log Message: Update compat/ossaudio with GETISPACE/GETOSPACE corrections from libossaudio. To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/sys/compat/ossaudio/ossaudio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/ossaudio/ossaudio.c diff -u src/sys/compat/ossaudio/ossaudio.c:1.69 src/sys/compat/ossaudio/ossaudio.c:1.70 --- src/sys/compat/ossaudio/ossaudio.c:1.69 Fri Sep 5 09:21:55 2014 +++ src/sys/compat/ossaudio/ossaudio.c Fri Mar 24 14:32:29 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ossaudio.c,v 1.69 2014/09/05 09:21:55 matt Exp $ */ +/* $NetBSD: ossaudio.c,v 1.70 2017/03/24 14:32:29 nat Exp $ */ /*- * Copyright (c) 1997, 2008 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.69 2014/09/05 09:21:55 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.70 2017/03/24 14:32:29 nat Exp $"); #include #include @@ -619,12 +619,11 @@ oss_ioctl_audio(struct lwp *l, const str } setblocksize(fp, ); bufinfo.fragsize = tmpinfo.blocksize; - bufinfo.fragments = tmpinfo.hiwat - - (tmpinfo.play.seek + tmpinfo.blocksize - 1) / + bufinfo.fragments = (tmpinfo.hiwat * tmpinfo.blocksize - + (tmpinfo.play.seek + tmpinfo.blocksize -1)) / tmpinfo.blocksize; bufinfo.fragstotal = tmpinfo.hiwat; - bufinfo.bytes = - tmpinfo.hiwat * tmpinfo.blocksize - tmpinfo.play.seek; + bufinfo.bytes = bufinfo.fragments * tmpinfo.blocksize; error = copyout(, SCARG(uap, data), sizeof bufinfo); if (error) { DPRINTF(("%s: SNDCTL_DSP_GETOSPACE = %d\n", @@ -641,12 +640,9 @@ oss_ioctl_audio(struct lwp *l, const str } setblocksize(fp, ); bufinfo.fragsize = tmpinfo.blocksize; - bufinfo.fragments = tmpinfo.hiwat - - (tmpinfo.record.seek + tmpinfo.blocksize - 1) / - tmpinfo.blocksize; -bufinfo.fragstotal = tmpinfo.hiwat; - bufinfo.bytes = - tmpinfo.hiwat * tmpinfo.blocksize - tmpinfo.record.seek; + bufinfo.fragments = tmpinfo.record.seek / tmpinfo.blocksize; + bufinfo.fragstotal = tmpinfo.hiwat; + bufinfo.bytes = bufinfo.fragments * tmpinfo.blocksize; error = copyout(, SCARG(uap, data), sizeof bufinfo); if (error) { DPRINTF(("%s: SNDCTL_DSP_GETISPACE %d %d %d %d = %d\n",
CVS commit: src/sys/compat/ossaudio
Module Name:src Committed By: jmcneill Date: Tue Sep 6 01:19:34 UTC 2011 Modified Files: src/sys/compat/ossaudio: ossaudio.c ossaudiovar.h Log Message: Add support for AFMT_AC3 To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/sys/compat/ossaudio/ossaudio.c cvs rdiff -u -r1.15 -r1.16 src/sys/compat/ossaudio/ossaudiovar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/ossaudio/ossaudio.c diff -u src/sys/compat/ossaudio/ossaudio.c:1.65 src/sys/compat/ossaudio/ossaudio.c:1.66 --- src/sys/compat/ossaudio/ossaudio.c:1.65 Sat Aug 22 23:31:16 2009 +++ src/sys/compat/ossaudio/ossaudio.c Tue Sep 6 01:19:34 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ossaudio.c,v 1.65 2009/08/22 23:31:16 christos Exp $ */ +/* $NetBSD: ossaudio.c,v 1.66 2011/09/06 01:19:34 jmcneill Exp $ */ /*- * Copyright (c) 1997, 2008 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ossaudio.c,v 1.65 2009/08/22 23:31:16 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: ossaudio.c,v 1.66 2011/09/06 01:19:34 jmcneill Exp $); #include sys/param.h #include sys/proc.h @@ -352,6 +352,12 @@ tmpinfo.play.encoding = tmpinfo.record.encoding = AUDIO_ENCODING_ULINEAR_BE; break; + case OSS_AFMT_AC3: + tmpinfo.play.precision = + tmpinfo.record.precision = 16; + tmpinfo.play.encoding = + tmpinfo.record.encoding = AUDIO_ENCODING_AC3; + break; default: DPRINTF((%s: SNDCTL_DSP_SETFMT bad fmt %d\n, __func__, idat)); @@ -408,6 +414,9 @@ case AUDIO_ENCODING_ADPCM: idat = OSS_AFMT_IMA_ADPCM; break; + case AUDIO_ENCODING_AC3: + idat = OSS_AFMT_AC3; + break; default: DPRINTF((%s: SOUND_PCM_READ_BITS bad encoding %d\n, __func__, tmpinfo.play.encoding)); @@ -583,6 +592,9 @@ case AUDIO_ENCODING_ADPCM: idat |= OSS_AFMT_IMA_ADPCM; break; + case AUDIO_ENCODING_AC3: +idat |= OSS_AFMT_AC3; +break; default: DPRINTF((%s: SNDCTL_DSP_GETFMTS unknown %d\n, __func__, tmpenc.encoding)); Index: src/sys/compat/ossaudio/ossaudiovar.h diff -u src/sys/compat/ossaudio/ossaudiovar.h:1.15 src/sys/compat/ossaudio/ossaudiovar.h:1.16 --- src/sys/compat/ossaudio/ossaudiovar.h:1.15 Mon Apr 28 20:23:45 2008 +++ src/sys/compat/ossaudio/ossaudiovar.h Tue Sep 6 01:19:34 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ossaudiovar.h,v 1.15 2008/04/28 20:23:45 martin Exp $ */ +/* $NetBSD: ossaudiovar.h,v 1.16 2011/09/06 01:19:34 jmcneill Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -99,6 +99,7 @@ #define OSS_AFMT_U16_LE 0x0080 /* Little endian U16 */ #define OSS_AFMT_U16_BE 0x0100 /* Big endian U16 */ #define OSS_AFMT_MPEG 0x0200 /* MPEG (2) audio */ +#define OSS_AFMT_AC3 0x0400 /* Dolby Digital AC3 */ /* Mixer defines */ #define OSS_SOUND_MIXER_FIRST 0
CVS commit: src/sys/compat/ossaudio
Module Name:src Committed By: christos Date: Sat Aug 22 23:31:16 UTC 2009 Modified Files: src/sys/compat/ossaudio: ossaudio.c Log Message: add a lot more debugging and error checking. Alas, skype seems to be happy getting back our values, but still does not work. To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/sys/compat/ossaudio/ossaudio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/ossaudio/ossaudio.c diff -u src/sys/compat/ossaudio/ossaudio.c:1.64 src/sys/compat/ossaudio/ossaudio.c:1.65 --- src/sys/compat/ossaudio/ossaudio.c:1.64 Thu Nov 13 05:05:52 2008 +++ src/sys/compat/ossaudio/ossaudio.c Sat Aug 22 19:31:16 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ossaudio.c,v 1.64 2008/11/13 10:05:52 ad Exp $ */ +/* $NetBSD: ossaudio.c,v 1.65 2009/08/22 23:31:16 christos Exp $ */ /*- * Copyright (c) 1997, 2008 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ossaudio.c,v 1.64 2008/11/13 10:05:52 ad Exp $); +__KERNEL_RCSID(0, $NetBSD: ossaudio.c,v 1.65 2009/08/22 23:31:16 christos Exp $); #include sys/param.h #include sys/proc.h @@ -66,6 +66,88 @@ static void setblocksize(file_t *, struct audio_info *); +#ifdef AUDIO_DEBUG +static const char * +compat_ossaudio_getcmd(u_long cmd) +{ + static char buf[64]; + switch (cmd) { +#define _DO(_a) \ + case _a: \ + return # _a; +_DO(OSS_SNDCTL_DSP_RESET) +_DO(OSS_SNDCTL_DSP_SYNC) +_DO(OSS_SNDCTL_DSP_SPEED) +_DO(OSS_SOUND_PCM_READ_RATE) +_DO(OSS_SNDCTL_DSP_STEREO) +_DO(OSS_SNDCTL_DSP_GETBLKSIZE) +_DO(OSS_SNDCTL_DSP_SETFMT) +_DO(OSS_SOUND_PCM_READ_BITS) +_DO(OSS_SNDCTL_DSP_CHANNELS) +_DO(OSS_SOUND_PCM_READ_CHANNELS) +_DO(OSS_SOUND_PCM_WRITE_FILTER) +_DO(OSS_SOUND_PCM_READ_FILTER) +_DO(OSS_SNDCTL_DSP_POST) +_DO(OSS_SNDCTL_DSP_SUBDIVIDE) +_DO(OSS_SNDCTL_DSP_SETFRAGMENT) +_DO(OSS_SNDCTL_DSP_GETFMTS) +_DO(OSS_SNDCTL_DSP_GETOSPACE) +_DO(OSS_SNDCTL_DSP_GETISPACE) +_DO(OSS_SNDCTL_DSP_NONBLOCK) +_DO(OSS_SNDCTL_DSP_GETCAPS) +_DO(OSS_SNDCTL_DSP_GETTRIGGER) +_DO(OSS_SNDCTL_DSP_SETTRIGGER) +_DO(OSS_SNDCTL_DSP_GETIPTR) +_DO(OSS_SNDCTL_DSP_GETOPTR) +_DO(OSS_SNDCTL_DSP_MAPINBUF) +_DO(OSS_SNDCTL_DSP_MAPOUTBUF) +_DO(OSS_SNDCTL_DSP_SETSYNCRO) +_DO(OSS_SNDCTL_DSP_SETDUPLEX) +_DO(OSS_SNDCTL_DSP_GETODELAY) +_DO(OSS_SNDCTL_DSP_PROFILE) +_DO(OSS_SOUND_MIXER_INFO) +_DO(OSS_SOUND_OLD_MIXER_INFO) +_DO(OSS_GET_VERSION) +_DO(OSS_SEQ_RESET) +_DO(OSS_SEQ_SYNC) +_DO(OSS_SYNTH_INFO) +_DO(OSS_SEQ_CTRLRATE) +_DO(OSS_SEQ_GETOUTCOUNT) +_DO(OSS_SEQ_GETINCOUNT) +_DO(OSS_SEQ_PERCMODE) +_DO(OSS_SEQ_TESTMIDI) +_DO(OSS_SEQ_RESETSAMPLES) +_DO(OSS_SEQ_NRSYNTHS) +_DO(OSS_SEQ_NRMIDIS) +#ifdef notyet +_DO(OSS_MIDI_INFO) +#endif +_DO(OSS_SEQ_THRESHOLD) +_DO(OSS_MEMAVL) +_DO(OSS_FM_4OP_ENABLE) +_DO(OSS_SEQ_PANIC) +_DO(OSS_SEQ_OUTOFBAND) +_DO(OSS_SEQ_GETTIME) +_DO(OSS_ID) +_DO(OSS_CONTROL) +_DO(OSS_REMOVESAMPLE) +_DO(OSS_TMR_TIMEBASE) +_DO(OSS_TMR_START) +_DO(OSS_TMR_STOP) +_DO(OSS_TMR_CONTINUE) +_DO(OSS_TMR_TEMPO) +_DO(OSS_TMR_SOURCE) +_DO(OSS_TMR_METRONOME) +_DO(OSS_TMR_SELECT) +#undef _DO + default: + (void)snprintf(buf, sizeof(buf), *0x%lx*, cmd); + return buf; + } +} +#endif + + static int compat_ossaudio_modcmd(modcmd_t cmd, void *arg) { @@ -108,7 +190,7 @@ } com = SCARG(uap, com); - DPRINTF((oss_ioctl_audio: com=%08lx\n, com)); + DPRINTF((%s: com=%s\n, __func__, compat_ossaudio_getcmd(com))); retval[0] = 0; @@ -116,13 +198,17 @@ switch (com) { case OSS_SNDCTL_DSP_RESET: error = ioctlf(fp, AUDIO_FLUSH, NULL); - if (error) + if (error) { + DPRINTF((%s: AUDIO_FLUSH %d\n, __func__, error)); goto out; + } break; case OSS_SNDCTL_DSP_SYNC: error = ioctlf(fp, AUDIO_DRAIN, NULL); - if (error) + if (error) { + DPRINTF((%s: AUDIO_DRAIN %d\n, __func__, error)); goto out; + } break; case OSS_SNDCTL_DSP_POST: /* This call is merely advisory, and may be a nop. */ @@ -130,56 +216,93 @@ case OSS_SNDCTL_DSP_SPEED: AUDIO_INITINFO(tmpinfo); error = copyin(SCARG(uap, data), idat, sizeof idat); - if (error) + if (error) { + DPRINTF((%s: SNDCTL_DSP_SPEED %d\n, + __func__, error)); goto out; + } tmpinfo.play.sample_rate = tmpinfo.record.sample_rate = idat; + DPRINTF((%s: SNDCTL_DSP_SPEED %d\n, __func__, idat)); error = ioctlf(fp, AUDIO_SETINFO, tmpinfo); - DPRINTF((oss_sys_ioctl: SNDCTL_DSP_SPEED %d = %d\n, - idat, error)); - if (error) + if (error) { + DPRINTF((%s: SNDCTL_DSP_SPEED %d = %d\n, + __func__, idat, error)); goto out; + } /* fall into ... */ case OSS_SOUND_PCM_READ_RATE: error = ioctlf(fp, AUDIO_GETBUFINFO, tmpinfo); - if (error) + if (error) { + DPRINTF((%s: AUDIO_GETBUFINFO %d\n, + __func__, error)); goto out; + } idat = tmpinfo.play.sample_rate; + DPRINTF((%s: SNDCTL_PCM_READ_RATE %d\n, __func__, idat)); error = copyout(idat, SCARG(uap, data), sizeof idat); - if (error) + if