Skip to content

Commit

Permalink
OpenZFS 6314 - buffer overflow in dsl_dataset_name
Browse files Browse the repository at this point in the history
Reviewed by: George Wilson <[email protected]>
Reviewed by: Prakash Surya <[email protected]>
Reviewed by: Igor Kozhukhov <[email protected]>
Approved by: Dan McDonald <[email protected]>
Ported-by: Brian Behlendorf <[email protected]>

OpenZFS-issue: https://www.illumos.org/issues/6314
OpenZFS-commit: openzfs/openzfs@d6160ee
  • Loading branch information
ikozhukhov authored and behlendorf committed Jun 28, 2016
1 parent 43e52ed commit eca7b76
Show file tree
Hide file tree
Showing 41 changed files with 298 additions and 335 deletions.
5 changes: 2 additions & 3 deletions cmd/zdb/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
#include <sys/ddt.h>
#include <sys/zfeature.h>
#include <zfs_comutil.h>
#undef ZFS_MAXNAMELEN
#include <libzfs.h>

#define ZDB_COMPRESS_NAME(idx) ((idx) < ZIO_COMPRESS_FUNCTIONS ? \
Expand Down Expand Up @@ -2005,7 +2004,7 @@ dump_dir(objset_t *os)
uint64_t refdbytes, usedobjs, scratch;
char numbuf[32];
char blkbuf[BP_SPRINTF_LEN + 20];
char osname[MAXNAMELEN];
char osname[ZFS_MAX_DATASET_NAME_LEN];
char *type = "UNKNOWN";
int verbosity = dump_opt['d'];
int print_header = 1;
Expand Down Expand Up @@ -3553,7 +3552,7 @@ find_zpool(char **target, nvlist_t **configp, int dirc, char **dirv)
nvlist_t *match = NULL;
char *name = NULL;
char *sepp = NULL;
char sep = 0;
char sep = '\0';
int count = 0;
importargs_t args = { 0 };

Expand Down
30 changes: 15 additions & 15 deletions cmd/zfs/zfs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1483,7 +1483,7 @@ get_callback(zfs_handle_t *zhp, void *data)
char buf[ZFS_MAXPROPLEN];
char rbuf[ZFS_MAXPROPLEN];
zprop_source_t sourcetype;
char source[ZFS_MAXNAMELEN];
char source[ZFS_MAX_DATASET_NAME_LEN];
zprop_get_cbdata_t *cbp = data;
nvlist_t *user_props = zfs_get_user_props(zhp);
zprop_list_t *pl = cbp->cb_proplist;
Expand Down Expand Up @@ -1963,7 +1963,7 @@ typedef struct upgrade_cbdata {
uint64_t cb_version;
boolean_t cb_newer;
boolean_t cb_foundone;
char cb_lastfs[ZFS_MAXNAMELEN];
char cb_lastfs[ZFS_MAX_DATASET_NAME_LEN];
} upgrade_cbdata_t;

static int
Expand Down Expand Up @@ -2412,7 +2412,7 @@ userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space)
if (domain != NULL && domain[0] != '\0') {
#ifdef HAVE_IDMAP
/* SMB */
char sid[ZFS_MAXNAMELEN + 32];
char sid[MAXNAMELEN + 32];
uid_t id;
uint64_t classes;
int err;
Expand Down Expand Up @@ -2546,7 +2546,7 @@ print_us_node(boolean_t scripted, boolean_t parsable, int *fields, int types,
size_t *width, us_node_t *node)
{
nvlist_t *nvl = node->usn_nvl;
char valstr[ZFS_MAXNAMELEN];
char valstr[MAXNAMELEN];
boolean_t first = B_TRUE;
int cfield = 0;
int field;
Expand Down Expand Up @@ -3417,7 +3417,7 @@ zfs_do_rollback(int argc, char **argv)
boolean_t force = B_FALSE;
rollback_cbdata_t cb = { 0 };
zfs_handle_t *zhp, *snap;
char parentname[ZFS_MAXNAMELEN];
char parentname[ZFS_MAX_DATASET_NAME_LEN];
char *delim;

/* check options */
Expand Down Expand Up @@ -3818,7 +3818,7 @@ zfs_do_send(int argc, char **argv)
*/
if (strchr(argv[0], '@') == NULL ||
(fromname && strchr(fromname, '#') != NULL)) {
char frombuf[ZFS_MAXNAMELEN];
char frombuf[ZFS_MAX_DATASET_NAME_LEN];
enum lzc_send_flags lzc_flags = 0;

if (flags.replicate || flags.doall || flags.props ||
Expand Down Expand Up @@ -3870,7 +3870,7 @@ zfs_do_send(int argc, char **argv)
* case if they specify the origin.
*/
if (fromname && (cp = strchr(fromname, '@')) != NULL) {
char origin[ZFS_MAXNAMELEN];
char origin[ZFS_MAX_DATASET_NAME_LEN];
zprop_source_t src;

(void) zfs_prop_get(zhp, ZFS_PROP_ORIGIN,
Expand Down Expand Up @@ -4004,7 +4004,7 @@ zfs_do_receive(int argc, char **argv)
usage(B_FALSE);
}

char namebuf[ZFS_MAXNAMELEN];
char namebuf[ZFS_MAX_DATASET_NAME_LEN];
(void) snprintf(namebuf, sizeof (namebuf),
"%s/%%recv", argv[0]);

Expand Down Expand Up @@ -4860,7 +4860,7 @@ store_allow_perm(zfs_deleg_who_type_t type, boolean_t local, boolean_t descend,
{
int i;
char ld[2] = { '\0', '\0' };
char who_buf[ZFS_MAXNAMELEN+32];
char who_buf[MAXNAMELEN + 32];
char base_type = ZFS_DELEG_WHO_UNKNOWN;
char set_type = ZFS_DELEG_WHO_UNKNOWN;
nvlist_t *base_nvl = NULL;
Expand Down Expand Up @@ -5224,7 +5224,7 @@ static void
print_fs_perms(fs_perm_set_t *fspset)
{
fs_perm_node_t *node = NULL;
char buf[ZFS_MAXNAMELEN+32];
char buf[MAXNAMELEN + 32];
const char *dsname = buf;

for (node = uu_list_first(fspset->fsps_list); node != NULL;
Expand All @@ -5233,7 +5233,7 @@ print_fs_perms(fs_perm_set_t *fspset)
uu_avl_t *uge_avl = node->fspn_fsperm.fsp_uge_avl;
int left = 0;

(void) snprintf(buf, ZFS_MAXNAMELEN+32,
(void) snprintf(buf, sizeof (buf),
gettext("---- Permissions on %s "),
node->fspn_fsperm.fsp_name);
(void) printf("%s", dsname);
Expand Down Expand Up @@ -5430,7 +5430,7 @@ zfs_do_hold_rele_impl(int argc, char **argv, boolean_t holding)

for (i = 0; i < argc; ++i) {
zfs_handle_t *zhp;
char parent[ZFS_MAXNAMELEN];
char parent[ZFS_MAX_DATASET_NAME_LEN];
const char *delim;
char *path = argv[i];

Expand Down Expand Up @@ -5558,7 +5558,7 @@ holds_callback(zfs_handle_t *zhp, void *data)
nvlist_t *nvl = NULL;
nvpair_t *nvp = NULL;
const char *zname = zfs_get_name(zhp);
size_t znamelen = strnlen(zname, ZFS_MAXNAMELEN);
size_t znamelen = strlen(zname);

if (cbp->cb_recursive) {
const char *snapname;
Expand All @@ -5579,7 +5579,7 @@ holds_callback(zfs_handle_t *zhp, void *data)

while ((nvp = nvlist_next_nvpair(nvl, nvp)) != NULL) {
const char *tag = nvpair_name(nvp);
size_t taglen = strnlen(tag, MAXNAMELEN);
size_t taglen = strlen(tag);
if (taglen > cbp->cb_max_taglen)
cbp->cb_max_taglen = taglen;
}
Expand Down Expand Up @@ -6695,7 +6695,7 @@ zfs_do_diff(int argc, char **argv)
static int
zfs_do_bookmark(int argc, char **argv)
{
char snapname[ZFS_MAXNAMELEN];
char snapname[ZFS_MAX_DATASET_NAME_LEN];
zfs_handle_t *zhp;
nvlist_t *nvl;
int ret = 0;
Expand Down
1 change: 0 additions & 1 deletion cmd/zhack/zhack.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#include <sys/zio_compress.h>
#include <sys/zfeature.h>
#include <sys/dmu_tx.h>
#undef ZFS_MAXNAMELEN
#include <libzfs.h>

extern boolean_t zfeature_checks_disable;
Expand Down
Loading

0 comments on commit eca7b76

Please sign in to comment.