Skip to content

Commit

Permalink
Fix zdb -E segfault
Browse files Browse the repository at this point in the history
SPA_MAXBLOCKSIZE is too large for stack.

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: loli10K <[email protected]>
Signed-off-by: Chunwei Chen <[email protected]>
Closes openzfs#7099
  • Loading branch information
davidchenntnx authored and tonyhutter committed Mar 8, 2018
1 parent 53a8259 commit 4d4e22e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/zdb/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -4139,11 +4139,12 @@ zdb_embedded_block(char *thing)
{
blkptr_t bp;
unsigned long long *words = (void *)&bp;
char buf[SPA_MAXBLOCKSIZE];
char *buf;
int err;

memset(&bp, 0, sizeof (blkptr_t));
buf = umem_alloc(SPA_MAXBLOCKSIZE, UMEM_NOFAIL);

bzero(&bp, sizeof (bp));
err = sscanf(thing, "%llx:%llx:%llx:%llx:%llx:%llx:%llx:%llx:"
"%llx:%llx:%llx:%llx:%llx:%llx:%llx:%llx",
words + 0, words + 1, words + 2, words + 3,
Expand All @@ -4161,6 +4162,7 @@ zdb_embedded_block(char *thing)
exit(1);
}
zdb_dump_block_raw(buf, BPE_GET_LSIZE(&bp), 0);
umem_free(buf, SPA_MAXBLOCKSIZE);
}

int
Expand Down

0 comments on commit 4d4e22e

Please sign in to comment.