diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index 8b5e5a4ed932..a1ace76d1585 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -3496,9 +3496,9 @@ dump_object(objset_t *os, uint64_t object, int verbosity, zdb_nicenum(doi.doi_physical_blocks_512 << 9, asize, sizeof (asize)); zdb_nicenum(doi.doi_bonus_size, bonus_size, sizeof (bonus_size)); zdb_nicenum(doi.doi_dnodesize, dnsize, sizeof (dnsize)); - (void) sprintf(fill, "%6.2f", 100.0 * doi.doi_fill_count * - doi.doi_data_block_size / (object == 0 ? DNODES_PER_BLOCK : 1) / - doi.doi_max_offset); + (void) snprintf(fill, sizeof (fill), "%6.2f", 100.0 * + doi.doi_fill_count * doi.doi_data_block_size / (object == 0 ? + DNODES_PER_BLOCK : 1) / doi.doi_max_offset); aux[0] = '\0'; @@ -5779,9 +5779,10 @@ zdb_ddt_leak_init(spa_t *spa, zdb_cb_t *zcb) ASSERT(ddt_phys_total_refcnt(&dde) > 1); + if (ddp->ddp_phys_birth == 0) + continue; + for (p = 0; p < DDT_PHYS_TYPES; p++, ddp++) { - if (ddp->ddp_phys_birth == 0) - continue; ddt_bp_create(ddb.ddb_checksum, &dde.dde_key, ddp, &blk); if (p == DDT_PHYS_DITTO) { diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 0b55bf21f448..0872671f428f 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -5429,7 +5429,13 @@ print_zpool_dir_scripts(char *dirpath) if ((dir = opendir(dirpath)) != NULL) { /* print all the files and directories within directory */ while ((ent = readdir(dir)) != NULL) { - sprintf(fullpath, "%s/%s", dirpath, ent->d_name); + if (snprintf(fullpath, sizeof (fullpath), "%s/%s", + dirpath, ent->d_name) >= sizeof (fullpath)) { + (void) fprintf(stderr, + gettext("internal error: " + "ZPOOL_SCRIPTS_PATH too large.\n")); + exit(1); + } /* Print the scripts */ if (stat(fullpath, &dir_stat) == 0) diff --git a/cmd/ztest.c b/cmd/ztest.c index 1c7c74c5d80f..605ce5cea3b6 100644 --- a/cmd/ztest.c +++ b/cmd/ztest.c @@ -1133,14 +1133,14 @@ process_options(int argc, char **argv) const char *invalid_what = "ztest"; char *val = zo->zo_alt_ztest; if (0 != access(val, X_OK) || - (strrchr(val, '/') == NULL && (errno = EINVAL))) + (strrchr(val, '/') == NULL && (errno == EINVAL))) goto invalid; int dirlen = strrchr(val, '/') - val; strlcpy(zo->zo_alt_libpath, val, MIN(sizeof (zo->zo_alt_libpath), dirlen + 1)); invalid_what = "library path", val = zo->zo_alt_libpath; - if (strrchr(val, '/') == NULL && (errno = EINVAL)) + if (strrchr(val, '/') == NULL && (errno == EINVAL)) goto invalid; *strrchr(val, '/') = '\0'; strlcat(val, "/lib", sizeof (zo->zo_alt_libpath)); diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index 87bc4ea66c5b..fd9fbd658a57 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -690,6 +690,7 @@ zfs_open(libzfs_handle_t *hdl, const char *path, int types) */ if (!zfs_validate_name(hdl, path, types, B_FALSE)) { (void) zfs_error(hdl, EZFS_INVALIDNAME, errbuf); + errno = EINVAL; return (NULL); } @@ -737,6 +738,7 @@ zfs_open(libzfs_handle_t *hdl, const char *path, int types) &cb_data) == 0) && (cb_data.zhp == NULL)) { (void) zfs_error(hdl, EZFS_NOENT, errbuf); zfs_close(pzhp); + errno = ENOENT; return (NULL); } if (cb_data.zhp == NULL) { @@ -755,6 +757,7 @@ zfs_open(libzfs_handle_t *hdl, const char *path, int types) if (!(types & zhp->zfs_type)) { (void) zfs_error(hdl, EZFS_BADTYPE, errbuf); zfs_close(zhp); + errno = EINVAL; return (NULL); } diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c index b53acdcea73e..089d46b130be 100644 --- a/lib/libzfs/libzfs_sendrecv.c +++ b/lib/libzfs/libzfs_sendrecv.c @@ -1289,7 +1289,7 @@ dump_filesystem(zfs_handle_t *zhp, send_dump_data_t *sdd) if (snap != NULL) rv = dump_snapshot(snap, sdd); else - rv = -1; + rv = errno; } /* Dump tosnap. */ @@ -1301,7 +1301,7 @@ dump_filesystem(zfs_handle_t *zhp, send_dump_data_t *sdd) if (snap != NULL) rv = dump_snapshot(snap, sdd); else - rv = -1; + rv = errno; } } diff --git a/module/zfs/dmu_send.c b/module/zfs/dmu_send.c index fbf19d5c3372..5ce2478e5611 100644 --- a/module/zfs/dmu_send.c +++ b/module/zfs/dmu_send.c @@ -1712,8 +1712,10 @@ enqueue_range(struct send_reader_thread_arg *srta, bqueue_t *q, dnode_t *dn, struct send_range *range = range_alloc(range_type, dn->dn_object, blkid, blkid + count, B_FALSE); - if (blkid == DMU_SPILL_BLKID) + if (blkid == DMU_SPILL_BLKID) { + ASSERT3P(bp, !=, NULL); ASSERT3U(BP_GET_TYPE(bp), ==, DMU_OT_SA); + } switch (range_type) { case HOLE: