From owner-freebsd-bugs Thu Dec 23 11:41:11 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from oberon.dnai.com (oberon.dnai.com [207.181.194.97]) by hub.freebsd.org (Postfix) with ESMTP id AE3C815849; Thu, 23 Dec 1999 11:41:08 -0800 (PST) (envelope-from kientzle@acm.org) Received: from acm.org (dnai-216-15-121-225.cust.dnai.com [216.15.121.225]) by oberon.dnai.com (8.9.3/8.9.3) with ESMTP id LAA07539; Thu, 23 Dec 1999 11:41:07 -0800 (PST) Message-ID: <38627AB8.AD0E4D37@acm.org> Date: Thu, 23 Dec 1999 11:40:40 -0800 From: Tim Kientzle Reply-To: kientzle@acm.org X-Mailer: Mozilla 4.5 [en] (X11; I; FreeBSD 3.3-RELEASE i386) X-Accept-Language: en MIME-Version: 1.0 To: gnats-admin@FreeBSD.org, freebsd-bugs@FreeBSD.org Subject: Re: kern/15639: msdosfs can't read large (3.8gig) files References: <199912230540.VAA80061@freefall.freebsd.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message