NetBSD Problem Report #9046

Received: (qmail 27444 invoked from network); 24 Dec 1999 01:42:36 -0000
Message-Id: <199912240142.CAA14148@cactus.emsi.priv.at>
Date: Fri, 24 Dec 1999 02:42:32 +0100 (CET)
From: "Martin J. Laubach" <mjl@emsi.priv.at>
Reply-To: mjl@emsi.priv.at
To: gnats-bugs@gnats.netbsd.org
Subject: msdosfs can't read large (3.8gig) files
X-Send-Pr-Version: 3.95

>Number:         9046
>Category:       kern
>Synopsis:       msdosfs can't read large (3.8gig) files
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    jdolecek
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Dec 23 17:45:01 +0000 1999
>Closed-Date:    Sat Apr 22 22:47:24 +0000 2000
>Last-Modified:  Sat Apr 22 22:47:24 +0000 2000
>Originator:     Martin J. Laubach
>Release:        19991210
>Organization:

>Environment:

System: NetBSD cactus.emsi.priv.at 1.4P NetBSD 1.4P (CACTUS) #0: Wed Dec 15 14:54:10 CET 1999 mjl@asparagus:/home/temp/devel/cvs/src/sys/arch/i386/compile/CACTUS i386


>Description:
  This comes from FreeBSD PR kern/15639. The submitter is
unable to copy large files from an MS-DOS partition (test
case: a 3.8 G file).

  Cross checking his fix with the NetBSD code base, the problem
is also present -- can someone with msdosfs knowledge please check
that this is the correct fix and commit it?

>How-To-Repeat:
>Fix:

-- From: Tim Kientzle <kientzle@acm.org> --

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

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: kern-bug-people->jdolecek 
Responsible-Changed-By: jdolecek 
Responsible-Changed-When: Mon Mar 27 02:01:29 PST 2000 
Responsible-Changed-Why:  
I'll take care of this one. 
State-Changed-From-To: open->closed 
State-Changed-By: jdolecek 
State-Changed-When: Sat Apr 22 15:46:25 PDT 2000 
State-Changed-Why:  
Slighly different fix applied and everything should be ok now, thanks. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.49 2026/05/14 01:52:41 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.