From nobody@FreeBSD.ORG  Wed Dec 22 21:30:04 1999
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id BFE3614D30; Wed, 22 Dec 1999 21:30:04 -0800 (PST)
Message-Id: <19991223053004.BFE3614D30@hub.freebsd.org>
Date: Wed, 22 Dec 1999 21:30:04 -0800 (PST)
From: kientzle@acm.org
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@freebsd.org
Subject: msdosfs can't read large (3.8gig) files
X-Send-Pr-Version: www-1.0

>Number:         15639
>Category:       kern
>Synopsis:       msdosfs can't read large (3.8gig) files
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Dec 22 21:40:00 PST 1999
>Closed-Date:    Wed Jan 12 22:35:26 PST 2000
>Last-Modified:  Wed Jan 12 22:37:03 PST 2000
>Originator:     Tim Kientzle
>Release:        3.3-RELEASE
>Organization:
>Environment:
FreeBSD clover.kientzle.com 3.3-RELEASE FreeBSD 3.3-RELEASE #1: Tue Oct 12 16:52:34 PDT 1999     root@clover.kientzle.com:/usr/src/sys/compile/CLOVER  i386			
>Description:
How to transfer a 3.8gig file from a distant Windows
computer to a FreeBSD machine?

I have a (fairly important) file sent me on a Windows-formatted
hard disk.  When I 'mount_msdos /dev/wd3s1' and then try
to 'cp /mnt/BigFile.avi /usr/tmp', I end up with a 0-byte
file in /usr/tmp.

>How-To-Repeat:

>Fix:
Note: if some knowledgable soul can give me pointers
to likely culprits in the msdosfs code, I'd happily
experiment.  This is a very important file, and I
need to access it very soon.

>Release-Note:
>Audit-Trail:

From: Steve Price <sprice@hiwaay.net>
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: kern/15639: msdosfs can't read large (3.8gig) files (fwd)
Date: Thu, 23 Dec 1999 13:50:29 -0600 (CST)

 ---------- Forwarded message ----------
 Date: Thu, 23 Dec 1999 11:40:40 -0800
 From: Tim Kientzle <kientzle@acm.org>
 To: gnats-admin@FreeBSD.ORG, freebsd-bugs@FreeBSD.ORG
 Subject: Re: kern/15639: msdosfs can't read large (3.8gig) files
 
 gnats-admin@FreeBSD.org wrote:
 > 
 > Thank you very much for your problem report.
 > It has the internal identification `kern/15639'.
 > The individual assigned to look at your
 > report is: freebsd-bugs.
 > 
 > >Category:       kern
 > >Responsible:    freebsd-bugs
 > >Synopsis:       msdosfs can't read large (3.8gig) files
 > >Arrival-Date:   Wed Dec 22 21:40:00 PST 1999
 
 I've since found a fix for this problem.  The bug
 is in 'msdosfs_vnops.c', in the function
 'msdosfs_read'.
 
 Early in that function, it computes fileSize minus
 requestedOffset, and stores the difference into a
 signed int.  With very large files, that int can
 overflow.  A better approach is to
 make 'diff' an unsigned long, use a direct comparison
 for the initial test, and then be cautious about comparing
 'diff' to the signed 'n':
 
                 if (dep->de_FileSize <= uio->uio_offset)
                         return (0);
                 /* Note: diff can be as large as 4gig! */
                 diff = dep->de_FileSize - uio->uio_offset;
                 /* Avoid setting n to a negative value */
                 if ((diff < n) && (diff < LONG_MAX))
                         n = diff;
 
 This change allowed me to successfully copy a 3.8gig file from
 an MSDOS-formatted hard disk.
 
 				- Tim Kientzle
 
 
State-Changed-From-To: open->closed 
State-Changed-By: bp 
State-Changed-When: Wed Jan 12 22:35:26 PST 2000 
State-Changed-Why:  
Fixed along with other 2GB bugs. Thanks! 
>Unformatted:
