From c86df7778fd1d93a74892f36fa6fec14d3d20707 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Wed, 10 Oct 2018 10:42:53 +0530 Subject: [PATCH 400/404] all: fix the format warnings due to strict check In the fix for CVE listed below, we added a strict format check, and that has revealed multiple issues with the formats. Fixed all warnings introduced because of the fix. Updates: CVE-2018-14661 BUG: 1637084 Change-Id: Ic1702b264fa4c8ad23d3836fcd1d6dc2ca8bc4b1 Signed-off-by: Amar Tumballi Reviewed-on: https://code.engineering.redhat.com/gerrit/152352 Reviewed-by: Xavi Hernandez Reviewed-by: Sunil Kumar Heggodu Gopala Acharya --- libglusterfs/src/fd.c | 2 +- libglusterfs/src/inode.c | 2 +- libglusterfs/src/iobuf.c | 8 ++++---- libglusterfs/src/stack.c | 6 +++--- libglusterfs/src/statedump.c | 11 ++++++----- rpc/rpc-lib/src/rpc-drc.c | 4 ++-- xlators/cluster/dht/src/dht-shared.c | 2 +- xlators/cluster/stripe/src/stripe.c | 4 ++-- xlators/debug/trace/src/trace.c | 2 +- xlators/features/quota/src/quota.c | 2 +- xlators/mount/fuse/src/fuse-bridge.c | 6 +++--- xlators/performance/io-cache/src/io-cache.c | 4 ++-- xlators/performance/nl-cache/src/nl-cache-helper.c | 6 +++--- xlators/performance/open-behind/src/open-behind.c | 2 +- xlators/performance/quick-read/src/quick-read.c | 4 ++-- xlators/performance/read-ahead/src/read-ahead.c | 6 ++---- xlators/performance/write-behind/src/write-behind.c | 6 +++--- xlators/protocol/client/src/client.c | 2 +- xlators/storage/posix/src/posix.c | 10 +++++----- 19 files changed, 44 insertions(+), 45 deletions(-) diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c index 27c8e13..ed80bd3 100644 --- a/libglusterfs/src/fd.c +++ b/libglusterfs/src/fd.c @@ -1050,7 +1050,7 @@ fd_dump (fd_t *fd, char *prefix) return; memset(key, 0, sizeof(key)); - gf_proc_dump_write("pid", "%llu", fd->pid); + gf_proc_dump_write("pid", "%" PRIu64, fd->pid); gf_proc_dump_write("refcount", "%d", fd->refcount); gf_proc_dump_write("flags", "%d", fd->flags); diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c index 1bc05a4..29d3c8f 100644 --- a/libglusterfs/src/inode.c +++ b/libglusterfs/src/inode.c @@ -2415,7 +2415,7 @@ inode_table_dump (inode_table_t *itable, char *prefix) } gf_proc_dump_build_key(key, prefix, "hashsize"); - gf_proc_dump_write(key, "%d", itable->hashsize); + gf_proc_dump_write(key, "%"GF_PRI_SIZET, itable->hashsize); gf_proc_dump_build_key(key, prefix, "name"); gf_proc_dump_write(key, "%s", itable->name); diff --git a/libglusterfs/src/iobuf.c b/libglusterfs/src/iobuf.c index f6b8558..a22dbd3 100644 --- a/libglusterfs/src/iobuf.c +++ b/libglusterfs/src/iobuf.c @@ -1169,7 +1169,7 @@ iobuf_arena_info_dump (struct iobuf_arena *iobuf_arena, const char *key_prefix) gf_proc_dump_build_key(key, key_prefix, "alloc_cnt"); gf_proc_dump_write(key, "%"PRIu64, iobuf_arena->alloc_cnt); gf_proc_dump_build_key(key, key_prefix, "max_active"); - gf_proc_dump_write(key, "%"PRIu64, iobuf_arena->max_active); + gf_proc_dump_write(key, "%d", iobuf_arena->max_active); gf_proc_dump_build_key(key, key_prefix, "page_size"); gf_proc_dump_write(key, "%"PRIu64, iobuf_arena->page_size); list_for_each_entry (trav, &iobuf_arena->active.list, list) { @@ -1202,9 +1202,9 @@ iobuf_stats_dump (struct iobuf_pool *iobuf_pool) } gf_proc_dump_add_section("iobuf.global"); gf_proc_dump_write("iobuf_pool","%p", iobuf_pool); - gf_proc_dump_write("iobuf_pool.default_page_size", "%d", - iobuf_pool->default_page_size); - gf_proc_dump_write("iobuf_pool.arena_size", "%d", + gf_proc_dump_write("iobuf_pool.default_page_size", "%" GF_PRI_SIZET, + iobuf_pool->default_page_size); + gf_proc_dump_write("iobuf_pool.arena_size", "%" GF_PRI_SIZET, iobuf_pool->arena_size); gf_proc_dump_write("iobuf_pool.arena_cnt", "%d", iobuf_pool->arena_cnt); diff --git a/libglusterfs/src/stack.c b/libglusterfs/src/stack.c index d64ac8a..6fbd2bb 100644 --- a/libglusterfs/src/stack.c +++ b/libglusterfs/src/stack.c @@ -144,7 +144,7 @@ gf_proc_dump_call_frame (call_frame_t *call_frame, const char *key_buf,...) out: if (ret) { gf_proc_dump_write("Unable to dump the frame information", - "(Lock acquisition failed) %p", my_frame); + "(Lock acquisition failed)"); return; } } @@ -183,7 +183,7 @@ gf_proc_dump_call_stack (call_stack_t *call_stack, const char *key_buf,...) gf_proc_dump_write("uid", "%d", call_stack->uid); gf_proc_dump_write("gid", "%d", call_stack->gid); gf_proc_dump_write("pid", "%d", call_stack->pid); - gf_proc_dump_write("unique", "%Ld", call_stack->unique); + gf_proc_dump_write("unique", "%" PRIu64, call_stack->unique); gf_proc_dump_write("lk-owner", "%s", lkowner_utoa (&call_stack->lk_owner)); if (call_stack->type == GF_OP_TYPE_FOP) @@ -222,7 +222,7 @@ gf_proc_dump_pending_frames (call_pool_t *call_pool) gf_proc_dump_add_section("global.callpool"); section_added = _gf_true; gf_proc_dump_write("callpool_address","%p", call_pool); - gf_proc_dump_write("callpool.cnt","%d", call_pool->cnt); + gf_proc_dump_write("callpool.cnt", "%" PRId64, call_pool->cnt); list_for_each_entry (trav, &call_pool->all_frames, all_frames) { diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c index e9ecef5..a123adb 100644 --- a/libglusterfs/src/statedump.c +++ b/libglusterfs/src/statedump.c @@ -240,10 +240,11 @@ gf_proc_dump_xlator_mem_info (xlator_t *xl) gf_proc_dump_add_section ("%s.%s - usage-type %s memusage", xl->type, xl->name, xl->mem_acct->rec[i].typestr); - gf_proc_dump_write ("size", "%u", xl->mem_acct->rec[i].size); + gf_proc_dump_write ("size", "%" GF_PRI_SIZET, + xl->mem_acct->rec[i].size); gf_proc_dump_write ("num_allocs", "%u", xl->mem_acct->rec[i].num_allocs); - gf_proc_dump_write ("max_size", "%u", + gf_proc_dump_write ("max_size", "%" GF_PRI_SIZET, xl->mem_acct->rec[i].max_size); gf_proc_dump_write ("max_num_allocs", "%u", xl->mem_acct->rec[i].max_num_allocs); @@ -275,9 +276,9 @@ gf_proc_dump_xlator_mem_info_only_in_use (xlator_t *xl) gf_proc_dump_add_section ("%s.%s - usage-type %d", xl->type, xl->name,i); - gf_proc_dump_write ("size", "%u", + gf_proc_dump_write ("size", "%" GF_PRI_SIZET, xl->mem_acct->rec[i].size); - gf_proc_dump_write ("max_size", "%u", + gf_proc_dump_write ("max_size", "%" GF_PRI_SIZET, xl->mem_acct->rec[i].max_size); gf_proc_dump_write ("num_allocs", "%u", xl->mem_acct->rec[i].num_allocs); @@ -475,7 +476,7 @@ gf_proc_dump_dict_info (glusterfs_ctx_t *ctx) total_dicts = GF_ATOMIC_GET (ctx->stats.total_dicts_used); total_pairs = GF_ATOMIC_GET (ctx->stats.total_pairs_used); - gf_proc_dump_write ("max-pairs-per-dict", "%u", + gf_proc_dump_write ("max-pairs-per-dict", "%" PRIu64, GF_ATOMIC_GET (ctx->stats.max_dict_pairs)); gf_proc_dump_write ("total-pairs-used", "%lu", total_pairs); gf_proc_dump_write ("total-dicts-used", "%lu", total_dicts); diff --git a/rpc/rpc-lib/src/rpc-drc.c b/rpc/rpc-lib/src/rpc-drc.c index fb7d2f1..f597432 100644 --- a/rpc/rpc-lib/src/rpc-drc.c +++ b/rpc/rpc-lib/src/rpc-drc.c @@ -565,10 +565,10 @@ rpcsvc_drc_priv (rpcsvc_drc_globals_t *drc) gf_proc_dump_write (key, "%d", drc->lru_factor); gf_proc_dump_build_key (key, "drc", "duplicate_request_count"); - gf_proc_dump_write (key, "%d", drc->cache_hits); + gf_proc_dump_write (key, "%" PRIu64, drc->cache_hits); gf_proc_dump_build_key (key, "drc", "in_transit_duplicate_requests"); - gf_proc_dump_write (key, "%d", drc->intransit_hits); + gf_proc_dump_write (key, "%" PRIu64, drc->intransit_hits); list_for_each_entry (client, &drc->clients_head, client_list) { gf_proc_dump_build_key (key, "client", "%d.ip-address", i); diff --git a/xlators/cluster/dht/src/dht-shared.c b/xlators/cluster/dht/src/dht-shared.c index 2f0d8ce..4aef8ff 100644 --- a/xlators/cluster/dht/src/dht-shared.c +++ b/xlators/cluster/dht/src/dht-shared.c @@ -179,7 +179,7 @@ dht_priv_dump (xlator_t *this) conf->du_stats[i].avail_inodes); snprintf (key, sizeof (key), "du_stats[%d].log", i); - gf_proc_dump_write (key, "%lu", + gf_proc_dump_write (key, "%" PRIu32, conf->du_stats[i].log); } } diff --git a/xlators/cluster/stripe/src/stripe.c b/xlators/cluster/stripe/src/stripe.c index 67006ab..6b32f7f 100644 --- a/xlators/cluster/stripe/src/stripe.c +++ b/xlators/cluster/stripe/src/stripe.c @@ -5688,12 +5688,12 @@ stripe_priv_dump (xlator_t *this) options = priv->pattern; while (options != NULL) { gf_proc_dump_write ("path_pattern", "%s", priv->pattern->path_pattern); - gf_proc_dump_write ("options_block_size", "%ul", options->block_size); + gf_proc_dump_write ("options_block_size", "%" PRIu64, options->block_size); options = options->next; } - gf_proc_dump_write ("block_size", "%ul", priv->block_size); + gf_proc_dump_write ("block_size", "%" PRIu64, priv->block_size); gf_proc_dump_write ("nodes-down", "%d", priv->nodes_down); gf_proc_dump_write ("first-child_down", "%d", priv->first_child_down); gf_proc_dump_write ("xattr_supported", "%d", priv->xattr_supported); diff --git a/xlators/debug/trace/src/trace.c b/xlators/debug/trace/src/trace.c index 34ac4ca..602e130 100644 --- a/xlators/debug/trace/src/trace.c +++ b/xlators/debug/trace/src/trace.c @@ -68,7 +68,7 @@ dump_history_trace (circular_buffer_t *cb, void *data) ".%"GF_PRI_SUSECONDS, cb->tv.tv_usec); gf_proc_dump_write ("TIME", "%s", timestr); - gf_proc_dump_write ("FOP", "%s\n", cb->data); + gf_proc_dump_write ("FOP", "%s\n", (char *)cb->data); return 0; } diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c index 3d68ffa..71068d3 100644 --- a/xlators/features/quota/src/quota.c +++ b/xlators/features/quota/src/quota.c @@ -5224,7 +5224,7 @@ quota_priv_dump (xlator_t *this) if (!priv) goto out; - gf_proc_dump_add_section ("xlators.features.quota.priv", this->name); + gf_proc_dump_add_section ("xlators.features.quota.priv"); ret = TRY_LOCK (&priv->lock); if (ret) diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 1c4f4e4..fbb4c53 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -5148,11 +5148,11 @@ fuse_priv_dump (xlator_t *this) private->proto_minor); gf_proc_dump_write("volfile", "%s", private->volfile?private->volfile:"None"); - gf_proc_dump_write("volfile_size", "%d", + gf_proc_dump_write("volfile_size", "%" GF_PRI_SIZET, private->volfile_size); gf_proc_dump_write("mount_point", "%s", private->mount_point); - gf_proc_dump_write("iobuf", "%u", + gf_proc_dump_write("iobuf", "%p", private->iobuf); gf_proc_dump_write("fuse_thread_started", "%d", (int)private->fuse_thread_started); @@ -5208,7 +5208,7 @@ dump_history_fuse (circular_buffer_t *cb, void *data) ".%"GF_PRI_SUSECONDS, cb->tv.tv_usec); gf_proc_dump_write ("TIME", "%s", timestr); - gf_proc_dump_write ("message", "%s\n", cb->data); + gf_proc_dump_write ("message", "%s\n", (char *)cb->data); return 0; } diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c index 700d8c2..de44ad2 100644 --- a/xlators/performance/io-cache/src/io-cache.c +++ b/xlators/performance/io-cache/src/io-cache.c @@ -2065,8 +2065,8 @@ ioc_priv_dump (xlator_t *this) gf_proc_dump_write ("cache_used", "%ld", priv->cache_used); gf_proc_dump_write ("inode_count", "%u", priv->inode_count); gf_proc_dump_write ("cache_timeout", "%u", priv->cache_timeout); - gf_proc_dump_write ("min-file-size", "%u", priv->min_file_size); - gf_proc_dump_write ("max-file-size", "%u", priv->max_file_size); + gf_proc_dump_write ("min-file-size", "%" PRIu64, priv->min_file_size); + gf_proc_dump_write ("max-file-size", "%" PRIu64, priv->max_file_size); } pthread_mutex_unlock (&priv->table_lock); out: diff --git a/xlators/performance/nl-cache/src/nl-cache-helper.c b/xlators/performance/nl-cache/src/nl-cache-helper.c index 583d67b..b6f1a17 100644 --- a/xlators/performance/nl-cache/src/nl-cache-helper.c +++ b/xlators/performance/nl-cache/src/nl-cache-helper.c @@ -1192,14 +1192,14 @@ nlc_dump_inodectx (xlator_t *this, inode_t *inode) gf_proc_dump_write ("state", "%"PRIu64, nlc_ctx->state); gf_proc_dump_write ("timer", "%p", nlc_ctx->timer); - gf_proc_dump_write ("cache-time", "%lld", nlc_ctx->cache_time); + gf_proc_dump_write ("cache-time", "%" GF_PRI_TIME, nlc_ctx->cache_time); gf_proc_dump_write ("cache-size", "%zu", nlc_ctx->cache_size); gf_proc_dump_write ("refd-inodes", "%"PRIu64, nlc_ctx->refd_inodes); if (IS_PE_VALID (nlc_ctx->state)) list_for_each_entry_safe (pe, tmp, &nlc_ctx->pe, list) { - gf_proc_dump_write ("pe", "%p, %s", pe, - pe->inode, pe->name); + gf_proc_dump_write ("pe", "%p, %p, %s", (void *)pe, + (void *)pe->inode, pe->name); } if (IS_NE_VALID (nlc_ctx->state)) diff --git a/xlators/performance/open-behind/src/open-behind.c b/xlators/performance/open-behind/src/open-behind.c index 2d77f2d..3245c8f 100644 --- a/xlators/performance/open-behind/src/open-behind.c +++ b/xlators/performance/open-behind/src/open-behind.c @@ -933,7 +933,7 @@ ob_fdctx_dump (xlator_t *this, fd_t *fd) gf_proc_dump_write ("open_frame", "%p", ob_fd->open_frame); if (ob_fd->open_frame) - gf_proc_dump_write ("open_frame.root.unique", "%p", + gf_proc_dump_write ("open_frame.root.unique", "%" PRIu64, ob_fd->open_frame->root->unique); gf_proc_dump_write ("loc.path", "%s", ob_fd->loc.path); diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c index ca228b8..e377ac3 100644 --- a/xlators/performance/quick-read/src/quick-read.c +++ b/xlators/performance/quick-read/src/quick-read.c @@ -796,7 +796,7 @@ qr_priv_dump (xlator_t *this) gf_proc_dump_add_section ("%s", key_prefix); - gf_proc_dump_write ("max_file_size", "%d", conf->max_file_size); + gf_proc_dump_write ("max_file_size", "%" PRIu64, conf->max_file_size); gf_proc_dump_write ("cache_timeout", "%d", conf->cache_timeout); if (!table) { @@ -811,7 +811,7 @@ qr_priv_dump (xlator_t *this) } gf_proc_dump_write ("total_files_cached", "%d", file_count); - gf_proc_dump_write ("total_cache_used", "%d", total_size); + gf_proc_dump_write ("total_cache_used", "%" PRIu64, total_size); out: return 0; diff --git a/xlators/performance/read-ahead/src/read-ahead.c b/xlators/performance/read-ahead/src/read-ahead.c index 74ddf49..e02ca9f 100644 --- a/xlators/performance/read-ahead/src/read-ahead.c +++ b/xlators/performance/read-ahead/src/read-ahead.c @@ -808,7 +808,6 @@ ra_fdctx_dump (xlator_t *this, fd_t *fd) int32_t ret = 0, i = 0; uint64_t tmp_file = 0; char *path = NULL; - char key[GF_DUMP_MAX_BUF_LEN] = {0, }; char key_prefix[GF_DUMP_MAX_BUF_LEN] = {0, }; fd_ctx_get (fd, this, &tmp_file); @@ -849,8 +848,7 @@ ra_fdctx_dump (xlator_t *this, fd_t *fd) for (page = file->pages.next; page != &file->pages; page = page->next) { - sprintf (key, "page[%d]", i); - gf_proc_dump_write (key, "%p", page[i++]); + gf_proc_dump_write ("page", "%d: %p", i++, (void *)page); ra_page_dump (page); } @@ -1075,7 +1073,7 @@ ra_priv_dump (xlator_t *this) if (ret) goto out; { - gf_proc_dump_write ("page_size", "%d", conf->page_size); + gf_proc_dump_write ("page_size", "%" PRIu64, conf->page_size); gf_proc_dump_write ("page_count", "%d", conf->page_count); gf_proc_dump_write ("force_atime_update", "%d", conf->force_atime_update); diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c index ef02e18..d655843 100644 --- a/xlators/performance/write-behind/src/write-behind.c +++ b/xlators/performance/write-behind/src/write-behind.c @@ -2765,8 +2765,8 @@ wb_priv_dump (xlator_t *this) gf_proc_dump_add_section ("%s", key_prefix); - gf_proc_dump_write ("aggregate_size", "%d", conf->aggregate_size); - gf_proc_dump_write ("window_size", "%d", conf->window_size); + gf_proc_dump_write ("aggregate_size", "%" PRIu64, conf->aggregate_size); + gf_proc_dump_write ("window_size", "%" PRIu64, conf->window_size); gf_proc_dump_write ("flush_behind", "%d", conf->flush_behind); gf_proc_dump_write ("trickling_writes", "%d", conf->trickling_writes); @@ -2798,7 +2798,7 @@ __wb_dump_requests (struct list_head *head, char *prefix) else gf_proc_dump_write ("wound", "no"); - gf_proc_dump_write ("generation-number", "%d", req->gen); + gf_proc_dump_write ("generation-number", "%" PRIu64, req->gen); gf_proc_dump_write ("req->op_ret", "%d", req->op_ret); gf_proc_dump_write ("req->op_errno", "%d", req->op_errno); diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c index 674f1aa..1e69977 100644 --- a/xlators/protocol/client/src/client.c +++ b/xlators/protocol/client/src/client.c @@ -2859,7 +2859,7 @@ client_priv_dump (xlator_t *this) list_for_each_entry(tmp, &conf->saved_fds, sfd_pos) { sprintf (key, "fd.%d.remote_fd", i); - gf_proc_dump_write(key, "%d", tmp->remote_fd); + gf_proc_dump_write(key, "%" PRId64, tmp->remote_fd); client_fd_lk_ctx_dump (this, tmp->lk_ctx, i); i++; } diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 7bfe780..e46fe99 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -6970,11 +6970,11 @@ posix_priv (xlator_t *this) if (!priv) return 0; - gf_proc_dump_write("base_path","%s", priv->base_path); - gf_proc_dump_write("base_path_length","%d", priv->base_path_length); - gf_proc_dump_write("max_read","%d", priv->read_value); - gf_proc_dump_write("max_write","%d", priv->write_value); - gf_proc_dump_write("nr_files","%ld", priv->nr_files); + gf_proc_dump_write("base_path", "%s", priv->base_path); + gf_proc_dump_write("base_path_length", "%d", priv->base_path_length); + gf_proc_dump_write("max_read", "%" PRId64, priv->read_value); + gf_proc_dump_write("max_write", "%" PRId64, priv->write_value); + gf_proc_dump_write("nr_files", "%ld", priv->nr_files); return 0; } -- 1.8.3.1