aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2014-03-13 18:46:28 -0400
committerRuss Cox <rsc@swtch.com>2014-03-13 18:46:28 -0400
commit219cf22d6863a21a7378fc5481bb05bbb6edd2dc (patch)
tree22578b0e1f1258d6bc799aa71623dd80a2e2d130
parente78ed7a67bbaa37dc57dfb37219f505c48755e14 (diff)
downloadplan9port-219cf22d6863a21a7378fc5481bb05bbb6edd2dc.tar.gz
plan9port-219cf22d6863a21a7378fc5481bb05bbb6edd2dc.tar.bz2
plan9port-219cf22d6863a21a7378fc5481bb05bbb6edd2dc.zip
acme, sam: handle >1GB files correctly
TBR=rsc https://codereview.appspot.com/74060043
-rw-r--r--src/cmd/acme/dat.h4
-rw-r--r--src/cmd/acme/disk.c3
-rw-r--r--src/cmd/sam/disk.c3
-rw-r--r--src/cmd/sam/sam.h4
4 files changed, 10 insertions, 4 deletions
diff --git a/src/cmd/acme/dat.h b/src/cmd/acme/dat.h
index d0feb095..5c156eb6 100644
--- a/src/cmd/acme/dat.h
+++ b/src/cmd/acme/dat.h
@@ -69,7 +69,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 */
@@ -80,7 +80,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/src/cmd/acme/disk.c b/src/cmd/acme/disk.c
index 857d9329..8d95fa1d 100644
--- a/src/cmd/acme/disk.c
+++ b/src/cmd/acme/disk.c
@@ -82,6 +82,9 @@ disknewblock(Disk *d, uint n)
b = blist;
blist = b->u.next;
b->addr = d->addr;
+ if(d->addr+size < d->addr){
+ error("temp file overflow");
+ }
d->addr += size;
}
b->u.n = n;
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];
};