Date: 10 Aug 2003 13:15:57 -0000 From: Rui Lopes <rui@ruilopes.com> To: FreeBSD-gnats-submit@FreeBSD.org Subject: docs/55445: [PATCH] off-by-one bug in example code Message-ID: <20030810131557.16509.qmail@ns.webtt.biz> Resent-Message-ID: <200308101320.h7ADK9su064194@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 55445 >Category: docs >Synopsis: [PATCH] off-by-one bug in example code >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-doc >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Sun Aug 10 06:20:09 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Rui Lopes >Release: FreeBSD 5.1-RELEASE i386 >Organization: >Environment: System: FreeBSD disty 5.1-RELEASE FreeBSD 5.1-RELEASE #0: Fri Jun 6 19:30:44 WEST 2003 root@disty:/usr/obj/usr/src/sys/DEBUGGER i386 >Description: Off-by-one bug fix for example code of chapter "13.4 Character Devices" of "FreeBSD Architecture Handbook". (en_US.ISO8859-1/books/arch-handbook/driverbasics/chapter.sgml) >How-To-Repeat: >Fix: --- chapter.sgml.patch begins here --- --- chapter.sgml.orig Sun Aug 10 13:51:37 2003 +++ chapter.sgml Sun Aug 10 13:52:54 2003 @@ -318,10 +318,10 @@ int err = 0; /* 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)); + err = copyin(uio->uio_iov->iov_base, echomsg->msg, MIN(uio->uio_iov->iov_len,BUFFERSIZE-1)); /* Now we need to null terminate */ - *(echomsg->msg + MIN(uio->uio_iov->iov_len,BUFFERSIZE)) = 0; + *(echomsg->msg + MIN(uio->uio_iov->iov_len,BUFFERSIZE-1)) = 0; /* Record the length */ echomsg->len = MIN(uio->uio_iov->iov_len,BUFFERSIZE); --- chapter.sgml.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030810131557.16509.qmail>