summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2002-03-14 20:41:51 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2002-03-14 20:41:51 +0000
commit3f6200b6da6a1545561ffd050f9bd87b57b0b480 (patch)
tree93919f46d3198a7ac34c4b125293c96dfd218ada /sbin
parent664594592b027192aadee83827fa39d430c954d0 (diff)
fix a few overflows by using off_t, not 32bit longs; some parts are from lucq.org; millert@ ok
Diffstat (limited to 'sbin')
-rw-r--r--sbin/dump/dump.h17
-rw-r--r--sbin/dump/traverse.c50
2 files changed, 30 insertions, 37 deletions
diff --git a/sbin/dump/dump.h b/sbin/dump/dump.h
index 75b68b8cb00..842d2617a73 100644
--- a/sbin/dump/dump.h
+++ b/sbin/dump/dump.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dump.h,v 1.10 2002/02/17 19:42:27 millert Exp $ */
+/* $OpenBSD: dump.h,v 1.11 2002/03/14 20:41:50 mickey Exp $ */
/* $NetBSD: dump.h,v 1.11 1997/06/05 11:13:20 lukem Exp $ */
/*-
@@ -72,10 +72,10 @@ int pipeout; /* true => output to standard output */
ino_t curino; /* current inumber; used globally */
int newtape; /* new tape flag */
int density; /* density in 0.1" units */
-u_int64_t tapesize; /* estimated tape size, blocks */
-long tsize; /* tape size in 0.1" units */
+off_t tapesize; /* estimated tape size, blocks */
+off_t tsize; /* tape size in 0.1" units */
int unlimited; /* if set, write to end of medium */
-long asize; /* number of 0.1" units written on current tape */
+off_t asize; /* number of 0.1" units written on current tape */
int etapes; /* estimated number of tapes */
int nonodump; /* if set, do not honor UF_NODUMP user flags */
@@ -103,11 +103,10 @@ void timeest(void);
/* mapping routines */
struct dinode;
-long blockest(struct dinode *dp);
-void mapfileino(ino_t, u_int64_t *, int *);
-int mapfiles(ino_t maxino, u_int64_t *tapesize, char *disk,
- char * const *dirv);
-int mapdirs(ino_t maxino, u_int64_t *tapesize);
+off_t blockest(struct dinode *dp);
+void mapfileino(ino_t, off_t *, int *);
+int mapfiles(ino_t maxino, off_t *tapesize, char *disk, char * const *dirv);
+int mapdirs(ino_t maxino, off_t *tapesize);
/* file dumping routines */
void blksout(daddr_t *blkp, int frags, ino_t ino);
diff --git a/sbin/dump/traverse.c b/sbin/dump/traverse.c
index 4f662dc22de..fd20b590a2e 100644
--- a/sbin/dump/traverse.c
+++ b/sbin/dump/traverse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: traverse.c,v 1.9 2002/02/19 19:39:38 millert Exp $ */
+/* $OpenBSD: traverse.c,v 1.10 2002/03/14 20:41:50 mickey Exp $ */
/* $NetBSD: traverse.c,v 1.17 1997/06/05 11:13:27 lukem Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)traverse.c 8.2 (Berkeley) 9/23/93";
#else
-static char rcsid[] = "$OpenBSD: traverse.c,v 1.9 2002/02/19 19:39:38 millert Exp $";
+static char rcsid[] = "$OpenBSD: traverse.c,v 1.10 2002/03/14 20:41:50 mickey Exp $";
#endif
#endif /* not lint */
@@ -71,15 +71,9 @@ static char rcsid[] = "$OpenBSD: traverse.c,v 1.9 2002/02/19 19:39:38 millert Ex
#define HASDUMPEDFILE 0x1
#define HASSUBDIRS 0x2
-#ifdef FS_44INODEFMT
-typedef quad_t fsizeT;
-#else
-typedef int32_t fsizeT;
-#endif
-
-static int dirindir(ino_t ino, daddr_t blkno, int level, long *size);
-static void dmpindir(ino_t ino, daddr_t blk, int level, fsizeT *size);
-static int searchdir(ino_t ino, daddr_t blkno, long size, long filesize);
+static int dirindir(ino_t ino, daddr_t blkno, int level, off_t *size);
+static void dmpindir(ino_t ino, daddr_t blk, int level, off_t *size);
+static int searchdir(ino_t ino, daddr_t blkno, long size, off_t filesize);
/*
* This is an estimation of the number of TP_BSIZE blocks in the file.
@@ -88,11 +82,11 @@ static int searchdir(ino_t ino, daddr_t blkno, long size, long filesize);
* (when some of the blocks are usually used for indirect pointers);
* hence the estimate may be high.
*/
-long
+off_t
blockest(dp)
struct dinode *dp;
{
- long blkest, sizeest;
+ off_t blkest, sizeest;
/*
* dp->di_size is the size of the file in bytes.
@@ -108,7 +102,7 @@ blockest(dp)
* dump blocks (sizeest vs. blkest in the indirect block
* calculation).
*/
- blkest = howmany(dbtob(dp->di_blocks), TP_BSIZE);
+ blkest = howmany(dbtob((off_t)dp->di_blocks), TP_BSIZE);
sizeest = howmany(dp->di_size, TP_BSIZE);
if (blkest > sizeest)
blkest = sizeest;
@@ -140,7 +134,7 @@ blockest(dp)
void
mapfileino(ino, tapesize, dirskipped)
ino_t ino;
- u_int64_t *tapesize;
+ off_t *tapesize;
int *dirskipped;
{
int mode;
@@ -174,7 +168,7 @@ mapfileino(ino, tapesize, dirskipped)
int
mapfiles(maxino, tapesize, disk, dirv)
ino_t maxino;
- u_int64_t *tapesize;
+ off_t *tapesize;
char *disk;
char * const *dirv;
{
@@ -191,7 +185,7 @@ mapfiles(maxino, tapesize, disk, dirv)
dumpabort(0);
}
if ((dirh = fts_open(dirv, FTS_PHYSICAL|FTS_SEEDOT|FTS_XDEV,
- (int (*)())NULL)) == NULL) {
+ (int (*)())NULL)) == NULL) {
msg("fts_open failed: %s\n", strerror(errno));
dumpabort(0);
}
@@ -277,13 +271,13 @@ mapfiles(maxino, tapesize, disk, dirv)
int
mapdirs(maxino, tapesize)
ino_t maxino;
- u_int64_t *tapesize;
+ off_t *tapesize;
{
struct dinode *dp;
int i, isdir;
char *map;
ino_t ino;
- long filesize;
+ off_t filesize;
int ret, change = 0;
isdir = 0; /* XXX just to get gcc to shut up */
@@ -299,8 +293,7 @@ mapdirs(maxino, tapesize)
for (ret = 0, i = 0; filesize > 0 && i < NDADDR; i++) {
if (dp->di_db[i] != 0)
ret |= searchdir(ino, dp->di_db[i],
- (long)dblksize(sblock, dp, i),
- filesize);
+ dblksize(sblock, dp, i), filesize);
if (ret & HASDUMPEDFILE)
filesize = 0;
else
@@ -337,7 +330,7 @@ dirindir(ino, blkno, ind_level, filesize)
ino_t ino;
daddr_t blkno;
int ind_level;
- long *filesize;
+ off_t *filesize;
{
int ret = 0;
int i;
@@ -376,11 +369,12 @@ searchdir(ino, blkno, size, filesize)
ino_t ino;
daddr_t blkno;
long size;
- long filesize;
+ off_t filesize;
{
struct direct *dp;
- long loc, ret = 0;
+ long loc;
char dblk[MAXBSIZE];
+ int ret = 0;
bread(fsbtodb(sblock, blkno), dblk, (int)size);
if (filesize < size)
@@ -425,7 +419,7 @@ dumpino(dp, ino)
ino_t ino;
{
int ind_level, cnt;
- fsizeT size;
+ off_t size;
char buf[TP_BSIZE];
if (newtape) {
@@ -504,7 +498,7 @@ dmpindir(ino, blk, ind_level, size)
ino_t ino;
daddr_t blk;
int ind_level;
- fsizeT *size;
+ off_t *size;
{
int i, cnt;
daddr_t idblk[MAXNINDIR];
@@ -635,14 +629,14 @@ getino(inum)
* Error recovery is attempted at most BREADEMAX times before seeking
* consent from the operator to continue.
*/
-int breaderrors = 0;
+int breaderrors = 0;
#define BREADEMAX 32
void
bread(blkno, buf, size)
daddr_t blkno;
char *buf;
- int size;
+ int size;
{
int cnt, i;