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 <behlendorf1@llnl.gov> Signed-off-by: loli10K <ezomori.nozomu@gmail.com> Closes #7917
This commit is contained in:
parent
81155b296d
commit
e0b7ff46c9
|
@ -384,11 +384,13 @@ 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));
|
||||
} else {
|
||||
nvlist_print(stdout, nv);
|
||||
nvlist_free(nv);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case DRR_END:
|
||||
|
|
Loading…
Reference in New Issue