Unconditionally null-terminate string read into spkr driver.
Submitted by: Ikuo Nakagawa <ikuo@isl.intec.co.jp>, PR#1488, but using Bruce Evans <bde@zeta.org.au>'s fix.
This commit is contained in:
parent
3271a3a4f3
commit
3bd9f6db7a
@ -4,7 +4,7 @@
|
||||
* v1.4 by Eric S. Raymond (esr@snark.thyrsus.com) Aug 1993
|
||||
* modified for FreeBSD by Andrew A. Chernov <ache@astral.msk.su>
|
||||
*
|
||||
* $Id: spkr.c,v 1.24 1996/03/27 19:07:33 bde Exp $
|
||||
* $Id: spkr.c,v 1.25 1996/07/20 18:48:54 joerg Exp $
|
||||
*/
|
||||
|
||||
#include "speaker.h"
|
||||
@ -514,7 +514,7 @@ spkrwrite(dev, uio, ioflag)
|
||||
|
||||
if (minor(dev) != 0)
|
||||
return(ENXIO);
|
||||
else if (uio->uio_resid > DEV_BSIZE) /* prevent system crashes */
|
||||
else if (uio->uio_resid > (DEV_BSIZE - 1)) /* prevent system crashes */
|
||||
return(E2BIG);
|
||||
else
|
||||
{
|
||||
@ -524,8 +524,11 @@ spkrwrite(dev, uio, ioflag)
|
||||
|
||||
n = uio->uio_resid;
|
||||
cp = spkr_inbuf->b_un.b_addr;
|
||||
if (!(error = uiomove(cp, n, uio)))
|
||||
error = uiomove(cp, n, uio);
|
||||
if (!error) {
|
||||
cp[n] = '\0';
|
||||
playstring(cp, n);
|
||||
}
|
||||
return(error);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
* v1.4 by Eric S. Raymond (esr@snark.thyrsus.com) Aug 1993
|
||||
* modified for FreeBSD by Andrew A. Chernov <ache@astral.msk.su>
|
||||
*
|
||||
* $Id: spkr.c,v 1.24 1996/03/27 19:07:33 bde Exp $
|
||||
* $Id: spkr.c,v 1.25 1996/07/20 18:48:54 joerg Exp $
|
||||
*/
|
||||
|
||||
#include "speaker.h"
|
||||
@ -514,7 +514,7 @@ spkrwrite(dev, uio, ioflag)
|
||||
|
||||
if (minor(dev) != 0)
|
||||
return(ENXIO);
|
||||
else if (uio->uio_resid > DEV_BSIZE) /* prevent system crashes */
|
||||
else if (uio->uio_resid > (DEV_BSIZE - 1)) /* prevent system crashes */
|
||||
return(E2BIG);
|
||||
else
|
||||
{
|
||||
@ -524,8 +524,11 @@ spkrwrite(dev, uio, ioflag)
|
||||
|
||||
n = uio->uio_resid;
|
||||
cp = spkr_inbuf->b_un.b_addr;
|
||||
if (!(error = uiomove(cp, n, uio)))
|
||||
error = uiomove(cp, n, uio);
|
||||
if (!error) {
|
||||
cp[n] = '\0';
|
||||
playstring(cp, n);
|
||||
}
|
||||
return(error);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user