diff options
author | avg <avg@FreeBSD.org> | 2017-12-04 16:47:19 +0000 |
---|---|---|
committer | avg <avg@FreeBSD.org> | 2017-12-04 16:47:19 +0000 |
commit | 6aa2ab9aa2cd1a217768662ae27a7994a9c3c4fc (patch) | |
tree | 7bca4def1b7bc3cd4ac77735130bc2cc8fc5549c /cddl/contrib/opensolaris | |
parent | 97c4db833af9367d6774e0de1845823d127a833b (diff) | |
download | FreeBSD-src-6aa2ab9aa2cd1a217768662ae27a7994a9c3c4fc.zip FreeBSD-src-6aa2ab9aa2cd1a217768662ae27a7994a9c3c4fc.tar.gz |
MFC r326150: zdb: use a heap allocation instead of a huge array on stack
Diffstat (limited to 'cddl/contrib/opensolaris')
-rw-r--r-- | cddl/contrib/opensolaris/cmd/zdb/zdb.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/cddl/contrib/opensolaris/cmd/zdb/zdb.c b/cddl/contrib/opensolaris/cmd/zdb/zdb.c index 6ca5047..186f7d2 100644 --- a/cddl/contrib/opensolaris/cmd/zdb/zdb.c +++ b/cddl/contrib/opensolaris/cmd/zdb/zdb.c @@ -3724,7 +3724,7 @@ zdb_embedded_block(char *thing) { blkptr_t bp = { 0 }; unsigned long long *words = (void *)&bp; - char buf[SPA_MAXBLOCKSIZE]; + char *buf; int err; err = sscanf(thing, "%llx:%llx:%llx:%llx:%llx:%llx:%llx:%llx:" @@ -3738,12 +3738,20 @@ zdb_embedded_block(char *thing) exit(1); } ASSERT3U(BPE_GET_LSIZE(&bp), <=, SPA_MAXBLOCKSIZE); + buf = malloc(SPA_MAXBLOCKSIZE); + if (buf == NULL) { + (void) fprintf(stderr, "%s: failed to allocate %llu bytes\n", + __func__, SPA_MAXBLOCKSIZE); + exit(1); + } err = decode_embedded_bp(&bp, buf, BPE_GET_LSIZE(&bp)); if (err != 0) { (void) printf("decode failed: %u\n", err); + free(buf); exit(1); } zdb_dump_block_raw(buf, BPE_GET_LSIZE(&bp), 0); + free(buf); } static boolean_t |