diff options
author | iedowse <iedowse@FreeBSD.org> | 2002-07-08 01:25:54 +0000 |
---|---|---|
committer | iedowse <iedowse@FreeBSD.org> | 2002-07-08 01:25:54 +0000 |
commit | bcbb96f592710407e8bada39837b3b2149bd462e (patch) | |
tree | a610250586af85d78b4a052fcde8d98d8bc4bec1 /sbin/dump/traverse.c | |
parent | 61d745fe2cd0fa5f11beb44daebdedcfffd1b33d (diff) | |
download | FreeBSD-src-bcbb96f592710407e8bada39837b3b2149bd462e.zip FreeBSD-src-bcbb96f592710407e8bada39837b3b2149bd462e.tar.gz |
Use a fixed MAXBSIZE-size auto array instead of a static pointer
to a malloc'd buffer in dmpindir() and dirindir(). These functions
recursively call themselves to handle deeper levels of indirect
blocks, so a single static buffer was not suitable.
Bug tracked down by: Don Lewis <dl-freebsd@catspoiler.org>
Approach suggested by: bde
Diffstat (limited to 'sbin/dump/traverse.c')
-rw-r--r-- | sbin/dump/traverse.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/sbin/dump/traverse.c b/sbin/dump/traverse.c index bd01ecb..b5aab4e 100644 --- a/sbin/dump/traverse.c +++ b/sbin/dump/traverse.c @@ -277,10 +277,8 @@ dirindir( { int ret = 0; int i; - static caddr_t idblk; + char idblk[MAXBSIZE]; - if (idblk == NULL && (idblk = malloc(sblock->fs_bsize)) == NULL) - quit("dirindir: cannot allocate indirect memory.\n"); bread(fsbtodb(sblock, blkno), idblk, (int)sblock->fs_bsize); if (ind_level <= 0) { for (i = 0; *filesize > 0 && i < NINDIR(sblock); i++) { @@ -501,10 +499,8 @@ static void dmpindir(ino_t ino, ufs2_daddr_t blk, int ind_level, off_t *size) { int i, cnt; - static caddr_t idblk; + char idblk[MAXBSIZE]; - if (idblk == NULL && (idblk = malloc(sblock->fs_bsize)) == NULL) - quit("dmpindir: cannot allocate indirect memory.\n"); if (blk != 0) bread(fsbtodb(sblock, blk), idblk, (int) sblock->fs_bsize); else |