From 1e0276afb301ef6f0a62498898701abda5fec643 Mon Sep 17 00:00:00 2001 From: Ian Dowse Date: Mon, 8 Jul 2002 01:25:54 +0000 Subject: [PATCH] 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 Approach suggested by: bde --- sbin/dump/traverse.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/sbin/dump/traverse.c b/sbin/dump/traverse.c index bd01ecb36047..b5aab4eac98b 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