Fix an off-by-one error in the example code.

PR:		docs/55445
Submitted by:	Rui Lopes <rui@ruilopes.com>
Approved by:	des (mentor)
This commit is contained in:
Hiten Pandya 2003-10-09 09:48:41 +00:00
parent 1ab68c4763
commit bf2dbf306a
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=18367

View file

@ -325,10 +325,10 @@ echo_write(dev_t dev, struct uio *uio, int ioflag)
/* Copy the string in from user memory to kernel memory */
err = copyin(uio->uio_iov->iov_base, echomsg->msg,
MIN(uio->uio_iov->iov_len,BUFFERSIZE));
MIN(uio->uio_iov->iov_len,BUFFERSIZE - 1));
/* Now we need to null terminate, then record the length */
*(echomsg->msg + MIN(uio->uio_iov->iov_len,BUFFERSIZE)) = 0;
*(echomsg->msg + MIN(uio->uio_iov->iov_len,BUFFERSIZE - 1)) = 0;
echomsg->len = MIN(uio->uio_iov->iov_len,BUFFERSIZE);
if (err != 0) {