From root@ns.webtt.biz  Sun Aug 10 06:13:47 2003
Return-Path: <root@ns.webtt.biz>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id ACFFF37B401
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 10 Aug 2003 06:13:47 -0700 (PDT)
Received: from ns.webtt.biz (ns.webtt.biz [64.239.29.225])
	by mx1.FreeBSD.org (Postfix) with SMTP id E887F43F3F
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 10 Aug 2003 06:13:46 -0700 (PDT)
	(envelope-from root@ns.webtt.biz)
Received: (qmail 16510 invoked by uid 0); 10 Aug 2003 13:15:57 -0000
Message-Id: <20030810131557.16509.qmail@ns.webtt.biz>
Date: 10 Aug 2003 13:15:57 -0000
From: Rui Lopes <rui@ruilopes.com>
Reply-To: Rui Lopes <rui@ruilopes.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] off-by-one bug in example code
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         55445
>Category:       docs
>Synopsis:       [PATCH] off-by-one bug in example code
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    hmp
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug 10 06:20:09 PDT 2003
>Closed-Date:    Thu Oct 09 03:57:55 PDT 2003
>Last-Modified:  Thu Oct 09 03:57:55 PDT 2003
>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:
Responsible-Changed-From-To: freebsd-doc->hmp 
Responsible-Changed-By: hmp 
Responsible-Changed-When: Wed Sep 24 19:04:50 PDT 2003 
Responsible-Changed-Why:  
I will work on this, after discussing with my mentor. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=55445 
State-Changed-From-To: open->closed 
State-Changed-By: hmp 
State-Changed-When: Thu Oct 9 03:57:44 PDT 2003 
State-Changed-Why:  
Thank you Rui, patch committed. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=55445 
>Unformatted:
