aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/zdb/zdb_il.c
diff options
context:
space:
mode:
authorDon Brady <[email protected]>2015-06-24 12:17:36 -0600
committerBrian Behlendorf <[email protected]>2015-06-26 14:14:31 -0700
commit017da6f063861a1dc3eea5a41c3de8b879d579bd (patch)
tree15e4085a6663fccf2d4bdf0789952627f1ecb3ef /cmd/zdb/zdb_il.c
parent784652c1f034bf5bf25d22b5b4056a6955331734 (diff)
Fix for recent zdb -h | -i crashes (seg fault)
Allocating SPA_MAXBLOCKSIZE on the stack is a bad idea (even with the old 128K size). Use malloc instead when allocating temporary block buffer memory. Signed-off-by: Don Brady <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #3522
Diffstat (limited to 'cmd/zdb/zdb_il.c')
-rw-r--r--cmd/zdb/zdb_il.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/cmd/zdb/zdb_il.c b/cmd/zdb/zdb_il.c
index b85ef7ddd..93b905793 100644
--- a/cmd/zdb/zdb_il.c
+++ b/cmd/zdb/zdb_il.c
@@ -124,7 +124,7 @@ zil_prt_rec_write(zilog_t *zilog, int txtype, lr_write_t *lr)
char *data, *dlimit;
blkptr_t *bp = &lr->lr_blkptr;
zbookmark_phys_t zb;
- char buf[SPA_MAXBLOCKSIZE];
+ char *buf;
int verbose = MAX(dump_opt['d'], dump_opt['i']);
int error;
@@ -135,6 +135,9 @@ zil_prt_rec_write(zilog_t *zilog, int txtype, lr_write_t *lr)
if (txtype == TX_WRITE2 || verbose < 5)
return;
+ if ((buf = malloc(SPA_MAXBLOCKSIZE)) == NULL)
+ return;
+
if (lr->lr_common.lrc_reclen == sizeof (lr_write_t)) {
(void) printf("%shas blkptr, %s\n", prefix,
!BP_IS_HOLE(bp) &&
@@ -145,13 +148,13 @@ zil_prt_rec_write(zilog_t *zilog, int txtype, lr_write_t *lr)
if (BP_IS_HOLE(bp)) {
(void) printf("\t\t\tLSIZE 0x%llx\n",
(u_longlong_t)BP_GET_LSIZE(bp));
- bzero(buf, sizeof (buf));
+ bzero(buf, SPA_MAXBLOCKSIZE);
(void) printf("%s<hole>\n", prefix);
- return;
+ goto exit;
}
if (bp->blk_birth < zilog->zl_header->zh_claim_txg) {
(void) printf("%s<block already committed>\n", prefix);
- return;
+ goto exit;
}
SET_BOOKMARK(&zb, dmu_objset_id(zilog->zl_os),
@@ -162,7 +165,7 @@ zil_prt_rec_write(zilog_t *zilog, int txtype, lr_write_t *lr)
bp, buf, BP_GET_LSIZE(bp), NULL, NULL,
ZIO_PRIORITY_SYNC_READ, ZIO_FLAG_CANFAIL, &zb));
if (error)
- return;
+ goto exit;
data = buf;
} else {
data = (char *)(lr + 1);
@@ -180,6 +183,8 @@ zil_prt_rec_write(zilog_t *zilog, int txtype, lr_write_t *lr)
data++;
}
(void) printf("\n");
+exit:
+ free(buf);
}
/* ARGSUSED */