Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Jan 2001 06:10:04 -0800 (PST)
From:      Bruce Evans <bde@zeta.org.au>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/24732: cmp can not compare files lager 2GB but smaller 4GB
Message-ID:  <200101301410.f0UEA4k56894@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/24732; it has been noted by GNATS.

From: Bruce Evans <bde@zeta.org.au>
To: kazarov@izmiran.rssi.ru
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: bin/24732: cmp can not compare files lager 2GB but smaller 4GB
Date: Wed, 31 Jan 2001 01:02:21 +1100 (EST)

 On Tue, 30 Jan 2001 kazarov@izmiran.rssi.ru wrote:
 
 > And tests shows that cmp cannot mmap two files of silze greate about 1213MB (on my system).
 
 This seems about right for i386's.  Two files have to be mapped below the
 kernel start address of 3G, so their size is limited to 1.5GB.  Big files,
 at least, have to be mapped after libraries, so there size is further
 limited.
 
 > So constant should be decreased to 1GB
 
 This is rather machine-dependent, and probably too large to be optimal
 anyway.
 
 To fix the machine-dependencies, I think cmp should just try to mmap
 both files and fall back to c_special() if this fails.  Note that
 the current check against SIZE_T_MAX is just to prevent overflow,
 but it is broken in several ways:
 (1) It SIZE_T_MAX with MIN(len1, len2), but it needs to compare with
     MAX(len1, len2) to prevent overflow when the lengths are cast to
     size_t.
 (2) It needs comapare SIZE_T_MAX with
     MAX(len1 + skip1 % pagesize, len2 + skip2 % pagesize) to prevent
     overflow when the adjusted lengths are passed to mmap().
 The casts in (1) are bogus anyway.  They are unnecessary if a prototype
 for mmap() is in scope and are in the wrong place otherwise (the whole
 adjusted lengths should be cast).
 
 Bruce
 
 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200101301410.f0UEA4k56894>