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:
parent
1ab68c4763
commit
bf2dbf306a
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/head/; revision=18367
1 changed files with 2 additions and 2 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue