]> git.proxmox.com Git - mirror_zfs.git/commitdiff
zstreamdump dumps core printing truncated nvlist
authorLOLi <loli10K@users.noreply.github.com>
Tue, 18 Sep 2018 16:43:09 +0000 (18:43 +0200)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 18 Sep 2018 16:43:09 +0000 (09:43 -0700)
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

cmd/zstreamdump/zstreamdump.c

index 6c7150b108eb4990b7b0f764c34d8cd7868ac86c..a2edefa92f3753369060b5ca983a34d292255942 100644 (file)
@@ -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;