diff options
author | Amar Tumballi <amarts@redhat.com> | 2018-11-06 22:47:41 +0530 |
---|---|---|
committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2018-11-09 14:03:02 +0000 |
commit | 83304fedb464fe3f97db662ce3e07bd948b7b7d9 (patch) | |
tree | e9bc09af05900b562a99bff6ff964ed19a9bf685 /libglusterfs/src/statedump.c | |
parent | 7136414bcc0426270f1df8720018af1b53fd228a (diff) |
all: fix the format string exceptions
Currently, there are possibilities in few places, where a user-controlled
(like filename, program parameter etc) string can be passed as 'fmt' for
printf(), which can lead to segfault, if the user's string contains '%s',
'%d' in it.
While fixing it, makes sense to make the explicit check for such issues
across the codebase, by making the format call properly.
Fixes: CVE-2018-14661
Fixes: bz#1647666
Change-Id: Ib547293f2d9eb618594cbff0df3b9c800e88bde4
Signed-off-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'libglusterfs/src/statedump.c')
-rw-r--r-- | libglusterfs/src/statedump.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c index 422fb05ede6..5c8f0fc627f 100644 --- a/libglusterfs/src/statedump.c +++ b/libglusterfs/src/statedump.c @@ -221,9 +221,10 @@ 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", xl->mem_acct->rec[i].max_size); + 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); gf_proc_dump_write("total_allocs", "%u", @@ -254,8 +255,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", xl->mem_acct->rec[i].size); - gf_proc_dump_write("max_size", "%u", xl->mem_acct->rec[i].max_size); + gf_proc_dump_write("size", "%" GF_PRI_SIZET, xl->mem_acct->rec[i].size); + 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); gf_proc_dump_write("max_num_allocs", "%u", xl->mem_acct->rec[i].max_num_allocs); @@ -378,8 +380,8 @@ gf_proc_dump_mempool_info(glusterfs_ctx_t *ctx) gf_proc_dump_write("-----", "-----"); gf_proc_dump_write("pool-name", "%s", pool->name); gf_proc_dump_write("active-count", "%" GF_PRI_ATOMIC, active); - gf_proc_dump_write("sizeof-type", "%d", pool->sizeof_type); - gf_proc_dump_write("padded-sizeof", "%lu", + gf_proc_dump_write("sizeof-type", "%lu", pool->sizeof_type); + gf_proc_dump_write("padded-sizeof", "%d", 1 << pool->pool->power_of_two); gf_proc_dump_write("size", "%lu", (1 << pool->pool->power_of_two) * active); @@ -465,7 +467,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", "%" GF_PRI_ATOMIC, 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); |