From 219cf22d6863a21a7378fc5481bb05bbb6edd2dc Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 13 Mar 2014 18:46:28 -0400 Subject: acme, sam: handle >1GB files correctly TBR=rsc https://codereview.appspot.com/74060043 --- src/cmd/sam/disk.c | 3 +++ src/cmd/sam/sam.h | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/cmd/sam') diff --git a/src/cmd/sam/disk.c b/src/cmd/sam/disk.c index 81c98389..50bbc077 100644 --- a/src/cmd/sam/disk.c +++ b/src/cmd/sam/disk.c @@ -75,6 +75,9 @@ disknewblock(Disk *d, uint n) b = blist; blist = b->u.next; b->addr = d->addr; + if(d->addr+size < d->addr){ + panic("temp file overflow"); + } d->addr += size; } b->u.n = n; diff --git a/src/cmd/sam/sam.h b/src/cmd/sam/sam.h index f182ec98..c2aaa070 100644 --- a/src/cmd/sam/sam.h +++ b/src/cmd/sam/sam.h @@ -113,7 +113,7 @@ enum struct Block { - uint addr; /* disk address in bytes */ + vlong addr; /* disk address in bytes */ union { uint n; /* number of used runes in block */ Block *next; /* pointer to next in free list */ @@ -123,7 +123,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