blobcli: do not read from an zero-length blob

Not all blobs have data: an lvstore's super blob is a common
example. Perform a size check prior to trying to dump the blob's
contents.

Signed-off-by: Mike Gerdts <mgerdts@nvidia.com>
Change-Id: Ic5bc1b11cdda72a36c6a3f4b4de0fd6f1a2948c6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11246
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Mike Gerdts 2021-11-18 04:00:04 +00:00 committed by Jim Harris
parent 76a577b082
commit 8389b65ad4

View File

@ -701,6 +701,12 @@ dump_imp_open_cb(void *cb_arg, struct spdk_blob *blob, int bserrno)
return;
}
if (cli_context->blob->active.num_clusters == 0) {
fclose(cli_context->fp);
spdk_blob_close(cli_context->blob, close_cb, cli_context);
return;
}
/* read a io_unit of data from the blob */
spdk_blob_io_read(cli_context->blob, cli_context->channel,
cli_context->buff, cli_context->io_unit_count,