Commits

Russ Cox  committed 93b3c33

acme, sam: handle >1GB files correctly

TBR=rsc
https://codereview.appspot.com/74060043

  • Participants
  • Parent commits 89f7e02

Comments (0)

Files changed (4)

File src/cmd/acme/dat.h

 
 struct Block
 {
-	uint		addr;	/* disk address in bytes */
+	vlong		addr;	/* disk address in bytes */
 	union
 	{
 		uint	n;		/* number of used runes in block */
 struct Disk
 {
 	int		fd;
-	uint		addr;	/* length of temp file */
+	vlong		addr;	/* length of temp file */
 	Block	*free[Maxblock/Blockincr+1];
 };
 

File src/cmd/acme/disk.c

 		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;

File src/cmd/sam/disk.c

 		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;

File src/cmd/sam/sam.h

 
 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 */
 struct Disk
 {
 	int		fd;
-	uint		addr;	/* length of temp file */
+	vlong		addr;	/* length of temp file */
 	Block		*free[Maxblock/Blockincr+1];
 };