docs/55445: [PATCH] off-by-one bug in example code

Rui Lopes rui at ruilopes.com
Sun Aug 10 13:20:11 UTC 2003


>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 at 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:



More information about the freebsd-doc mailing list