Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Jun 2022 18:01:15 GMT
From:      Eugene Grosbein <eugen@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 02acb1db346e - stable/12 - MFC: fetch: make -S argument accept values > 2GB
Message-ID:  <202206061801.256I1FNR063153@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by eugen:

URL: https://cgit.FreeBSD.org/src/commit/?id=02acb1db346eccba328c35c2f5db8bd581f74839

commit 02acb1db346eccba328c35c2f5db8bd581f74839
Author:     Stefan Eßer <se@FreeBSD.org>
AuthorDate: 2022-02-20 14:24:43 +0000
Commit:     Eugene Grosbein <eugen@FreeBSD.org>
CommitDate: 2022-06-06 18:00:27 +0000

    MFC: fetch: make -S argument accept values > 2GB
    
    Use strtoll() to parse the argument of the -S option.
    
    FreeBSD has supported 64 bit file offsets for more than 25 years on
    all architectures and off_t is a 64 bit integer type for that reason.
    
    While strtol() returns a 64 bit value on 64 LP64 architectures, it
    is limit to 32 bit on e.g. i386. The strtoll() function returns a 64
    but result on all supported architectures and therefore supports the
    possible file lengths and file offsets on 32 bit archtectures.
    
    Reported by:    antoine
    
    (cherry picked from commit 32066c96fa00fc19c8355e1956ca5aa9ead37673)
---
 usr.bin/fetch/fetch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr.bin/fetch/fetch.c b/usr.bin/fetch/fetch.c
index 73ee96541859..ad51de15f4d3 100644
--- a/usr.bin/fetch/fetch.c
+++ b/usr.bin/fetch/fetch.c
@@ -1005,7 +1005,7 @@ main(int argc, char *argv[])
 			r_flag = 1;
 			break;
 		case 'S':
-			S_size = (off_t)strtol(optarg, &end, 10);
+			S_size = strtoll(optarg, &end, 10);
 			if (*optarg == '\0' || *end != '\0')
 				errx(1, "invalid size (%s)", optarg);
 			break;



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