aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/zstreamdump
diff options
context:
space:
mode:
authorLOLi <[email protected]>2018-09-18 18:43:09 +0200
committerBrian Behlendorf <[email protected]>2018-09-18 09:43:09 -0700
commite0b7ff46c98ef19afe58b21df9255d243de1a662 (patch)
tree7b5a7a0770f6250d2dd2e45210e3861ba039779f /cmd/zstreamdump
parent81155b296d88b6db1f526832e3e855e3b3b20fc9 (diff)
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 <[email protected]> Signed-off-by: loli10K <[email protected]> Closes #7917
Diffstat (limited to 'cmd/zstreamdump')
-rw-r--r--cmd/zstreamdump/zstreamdump.c8
1 files 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;