diff options
author | Dmitry Antipov <dmantipov@yandex.ru> | 2020-06-02 12:28:17 +0300 |
---|---|---|
committer | Sanju Rakonde <sanjurakonde@review.gluster.org> | 2020-06-10 15:43:44 +0000 |
commit | e150d758259a98421eb7711fb3855eb7691e2eda (patch) | |
tree | 12c4cb384404349c30139ed422f8b27ce76b3326 /cli/src/cli-xml-output.c | |
parent | 955bfd567329cf7fe63e9c3b89d333a55e5e9a20 (diff) |
cli: fix several signed integer overflows and format specifiers
Initially found with GCC UBsan:
cli/src/cli-rpc-ops.c:5347:73: runtime error: left shift of 1 by 31
places cannot be represented in type 'int'
cli/src/cli-rpc-ops.c:5355:74: runtime error: left shift of 1 by 31
places cannot be represented in type 'int'
Ditto in cli/src/cli-xml-output.c.
Change-Id: I14ed51d06dafe5039f154b0c4edf25a0997d696e
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Fixes: #1279
Diffstat (limited to 'cli/src/cli-xml-output.c')
-rw-r--r-- | cli/src/cli-xml-output.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c index 5f33aa9e0a3..01dd22b7192 100644 --- a/cli/src/cli-xml-output.c +++ b/cli/src/cli-xml-output.c @@ -1953,11 +1953,11 @@ cli_xml_output_vol_profile_stats(xmlTextWriterPtr writer, dict_t *dict, XML_RET_CHECK_AND_GOTO(ret, out); ret = xmlTextWriterWriteFormatElement(writer, (xmlChar *)"size", - "%" PRIu32, (1 << i)); + "%" PRIu32, (1U << i)); XML_RET_CHECK_AND_GOTO(ret, out); - snprintf(key, sizeof(key), "%d-%d-read-%d", brick_index, interval, - (1 << i)); + snprintf(key, sizeof(key), "%d-%d-read-%" PRIu32, brick_index, interval, + (1U << i)); ret = dict_get_uint64(dict, key, &read_count); if (ret) read_count = 0; @@ -1965,8 +1965,8 @@ cli_xml_output_vol_profile_stats(xmlTextWriterPtr writer, dict_t *dict, "%" PRIu64, read_count); XML_RET_CHECK_AND_GOTO(ret, out); - snprintf(key, sizeof(key), "%d-%d-write-%d", brick_index, interval, - (1 << i)); + snprintf(key, sizeof(key), "%d-%d-write-%" PRIu32, brick_index, + interval, (1U << i)); ret = dict_get_uint64(dict, key, &write_count); if (ret) write_count = 0; |