From a181f3dd3e922e7acc5a3f4982584e845bddec3c Mon Sep 17 00:00:00 2001 From: Ori Bernstein Date: Wed, 4 Dec 2019 11:46:42 -0800 Subject: acme, sam: handle >1GB files correctly imported from plan9port, edfe3c016fe6ef10c55f7a17aab668214ec21efc --- sys/src/cmd/acme/dat.h | 4 ++-- sys/src/cmd/acme/disk.c | 3 +++ sys/src/cmd/sam/disk.c | 3 +++ sys/src/cmd/sam/sam.h | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/src/cmd/acme/dat.h b/sys/src/cmd/acme/dat.h index 070be119b..bfc16e913 100644 --- a/sys/src/cmd/acme/dat.h +++ b/sys/src/cmd/acme/dat.h @@ -68,7 +68,7 @@ struct Range struct Block { - uint addr; /* disk address in bytes */ + vlong addr; /* disk address in bytes */ union { uint n; /* number of used runes in block */ @@ -79,7 +79,7 @@ struct Block struct Disk { int fd; - uint addr; /* length of temp file */ + vlong addr; /* length of temp file */ Block *free[Maxblock/Blockincr+1]; }; diff --git a/sys/src/cmd/acme/disk.c b/sys/src/cmd/acme/disk.c index 9b76a5582..8eb461a49 100644 --- a/sys/src/cmd/acme/disk.c +++ b/sys/src/cmd/acme/disk.c @@ -82,6 +82,9 @@ disknewblock(Disk *d, uint n) b = blist; blist = b->next; b->addr = d->addr; + if(d->addr+size < d->addr){ + error("temp file overflow"); + } d->addr += size; } b->n = n; diff --git a/sys/src/cmd/sam/disk.c b/sys/src/cmd/sam/disk.c index 47b30bda4..e822f4811 100644 --- a/sys/src/cmd/sam/disk.c +++ b/sys/src/cmd/sam/disk.c @@ -71,6 +71,9 @@ disknewblock(Disk *d, uint n) b = blist; blist = b->next; b->addr = d->addr; + if(d->addr+size < d->addr){ + panic("temp file overflow"); + } d->addr += size; } b->n = n; diff --git a/sys/src/cmd/sam/sam.h b/sys/src/cmd/sam/sam.h index f1cbd8ac0..f99fdae46 100644 --- a/sys/src/cmd/sam/sam.h +++ b/sys/src/cmd/sam/sam.h @@ -117,7 +117,7 @@ struct Block struct Disk { int fd; - uint addr; /* length of temp file */ + vlong addr; /* length of temp file */ Block *free[Maxblock/Blockincr+1]; }; -- cgit v1.2.3