]> git.proxmox.com Git - mirror_zfs.git/commit
Do not pass -1 to strerror() from zfs_send_cb_impl()
authorRichard Yao <richard.yao@alumni.stonybrook.edu>
Sun, 4 Dec 2022 22:03:14 +0000 (17:03 -0500)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 8 Dec 2022 22:15:27 +0000 (14:15 -0800)
commit5f73bbba436748654bf4fd6596c9cdba1a9914f3
tree4f58f9a003f3faca736932d70186a80d72622169
parent242a5b748cbf02001a1324f3e195df56f8f28f5a
Do not pass -1 to strerror() from zfs_send_cb_impl()

`zfs_send_cb_impl()` calls `dump_filesystems()`, which calls
`dump_filesystem()`, which will return `-1` as an error when
`zfs_open()` returns `NULL`.

This will be passed to `zfs_standard_error()`, which passes it to
`zfs_standard_error_fmt()`, which passes it to `strerror()`.

To fix this, we modify zfs_open() to set `errno` whenever it returns
NULL. Most of the cases already have `errno` set (since they pass it to
`zfs_standard_error_fmt()`, which makes this easy. Then we modify
`dump_filesystem()` to pass `errno` instead of `-1`.

Reported-by: Coverity (CID-1524598)
Reviewed-by: Damian Szuberski <szuberskidamian@gmail.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14264
lib/libzfs/libzfs_dataset.c
lib/libzfs/libzfs_sendrecv.c