ref: a181f3dd3e922e7acc5a3f4982584e845bddec3c
parent: f7db45e62852ba716539247e20eaaa027b5b1c67
author: Ori Bernstein <ori@eigenstate.org>
date: Wed Dec 4 06:46:42 EST 2019
acme, sam: handle >1GB files correctly imported from plan9port, edfe3c016fe6ef10c55f7a17aab668214ec21efc
--- a/sys/src/cmd/acme/dat.h
+++ b/sys/src/cmd/acme/dat.h
@@ -68,7 +68,7 @@
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 Disk
{
int fd;
- uint addr; /* length of temp file */
+ vlong addr; /* length of temp file */
Block *free[Maxblock/Blockincr+1];
};
--- a/sys/src/cmd/acme/disk.c
+++ b/sys/src/cmd/acme/disk.c
@@ -82,6 +82,9 @@
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;
--- a/sys/src/cmd/sam/disk.c
+++ b/sys/src/cmd/sam/disk.c
@@ -71,6 +71,9 @@
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;
--- a/sys/src/cmd/sam/sam.h
+++ b/sys/src/cmd/sam/sam.h
@@ -117,7 +117,7 @@
struct Disk
{
int fd;
- uint addr; /* length of temp file */
+ vlong addr; /* length of temp file */
Block *free[Maxblock/Blockincr+1];
};