diff options
author | Jorgen Lundman <[email protected]> | 2020-06-08 03:42:12 +0900 |
---|---|---|
committer | GitHub <[email protected]> | 2020-06-07 11:42:12 -0700 |
commit | c9e319faae9677aa0dddfbf9973b9e8fc3feb06c (patch) | |
tree | 3d6677913e5f26d91b7f35bcb62b9b354287db61 /module/zfs/zfs_quota.c | |
parent | 60265072e02049be708f74cf0865eba2434a2d85 (diff) |
Replace sprintf()->snprintf() and strcpy()->strlcpy()
The strcpy() and sprintf() functions are deprecated on some platforms.
Care is needed to ensure correct size is used. If some platforms
miss snprintf, we can add a #define to sprintf, likewise strlcpy().
The biggest change is adding a size parameter to zfs_id_to_fuidstr().
The various *_impl_get() functions are only used on linux and have
not yet been updated.
Reviewed by: Sean Eric Fagan <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Jorgen Lundman <[email protected]>
Closes #10400
Diffstat (limited to 'module/zfs/zfs_quota.c')
-rw-r--r-- | module/zfs/zfs_quota.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/module/zfs/zfs_quota.c b/module/zfs/zfs_quota.c index 1acfbf1ea..6c83f79c9 100644 --- a/module/zfs/zfs_quota.c +++ b/module/zfs/zfs_quota.c @@ -269,7 +269,8 @@ zfs_userspace_one(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type, offset = DMU_OBJACCT_PREFIX_LEN; } - err = zfs_id_to_fuidstr(zfsvfs, domain, rid, buf + offset, B_FALSE); + err = zfs_id_to_fuidstr(zfsvfs, domain, rid, buf + offset, + sizeof (buf) - offset, B_FALSE); if (err) return (err); @@ -325,7 +326,7 @@ zfs_set_userquota(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type, return (SET_ERROR(EINVAL)); } - err = zfs_id_to_fuidstr(zfsvfs, domain, rid, buf, B_TRUE); + err = zfs_id_to_fuidstr(zfsvfs, domain, rid, buf, sizeof (buf), B_TRUE); if (err) return (err); fuid_dirtied = zfsvfs->z_fuid_dirty; @@ -407,12 +408,13 @@ zfs_id_overobjquota(zfsvfs_t *zfsvfs, uint64_t usedobj, uint64_t id) if (quotaobj == 0 || zfsvfs->z_replay) return (B_FALSE); - (void) sprintf(buf, "%llx", (longlong_t)id); + (void) snprintf(buf, sizeof (buf), "%llx", (longlong_t)id); err = zap_lookup(zfsvfs->z_os, quotaobj, buf, 8, 1, "a); if (err != 0) return (B_FALSE); - (void) sprintf(buf, DMU_OBJACCT_PREFIX "%llx", (longlong_t)id); + (void) snprintf(buf, sizeof (buf), DMU_OBJACCT_PREFIX "%llx", + (longlong_t)id); err = zap_lookup(zfsvfs->z_os, usedobj, buf, 8, 1, &used); if (err != 0) return (B_FALSE); @@ -448,7 +450,7 @@ zfs_id_overblockquota(zfsvfs_t *zfsvfs, uint64_t usedobj, uint64_t id) if (quotaobj == 0 || zfsvfs->z_replay) return (B_FALSE); - (void) sprintf(buf, "%llx", (longlong_t)id); + (void) snprintf(buf, sizeof (buf), "%llx", (longlong_t)id); err = zap_lookup(zfsvfs->z_os, quotaobj, buf, 8, 1, "a); if (err != 0) return (B_FALSE); |