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
cmd/zstreamdump
|
@ -384,10 +384,12 @@ main(int argc, char *argv[])
|
||||||
if (ferror(send_stream))
|
if (ferror(send_stream))
|
||||||
perror("fread");
|
perror("fread");
|
||||||
err = nvlist_unpack(buf, sz, &nv, 0);
|
err = nvlist_unpack(buf, sz, &nv, 0);
|
||||||
if (err)
|
if (err) {
|
||||||
perror(strerror(err));
|
perror(strerror(err));
|
||||||
nvlist_print(stdout, nv);
|
} else {
|
||||||
nvlist_free(nv);
|
nvlist_print(stdout, nv);
|
||||||
|
nvlist_free(nv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue