From e0b7ff46c98ef19afe58b21df9255d243de1a662 Mon Sep 17 00:00:00 2001 From: LOLi Date: Tue, 18 Sep 2018 18:43:09 +0200 Subject: [PATCH] zstreamdump dumps core printing truncated nvlist This change prevents zstreamdump from crashing when trying to print invalid nvlist data (DRR_BEGIN record) from a truncated send stream. Reviewed-by: Brian Behlendorf Signed-off-by: loli10K Closes #7917 --- cmd/zstreamdump/zstreamdump.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/zstreamdump/zstreamdump.c b/cmd/zstreamdump/zstreamdump.c index 6c7150b10..a2edefa92 100644 --- a/cmd/zstreamdump/zstreamdump.c +++ b/cmd/zstreamdump/zstreamdump.c @@ -384,10 +384,12 @@ main(int argc, char *argv[]) if (ferror(send_stream)) perror("fread"); err = nvlist_unpack(buf, sz, &nv, 0); - if (err) + if (err) { perror(strerror(err)); - nvlist_print(stdout, nv); - nvlist_free(nv); + } else { + nvlist_print(stdout, nv); + nvlist_free(nv); + } } break;