From e0d68da6d6db7f150b1f6cbe691dfa3b60fb3a45 Mon Sep 17 00:00:00 2001 From: lemon0910 Date: Sat, 5 Jun 2021 17:43:07 +0800 Subject: [PATCH] fix coverity bug --- src/obproxy/proxy/mysqllib/ob_2_0_protocol_utils.cpp | 2 +- src/obproxy/proxy/mysqllib/ob_mysql_analyzer_utils.cpp | 2 +- src/obproxy/stat/ob_stat_processor.cpp | 2 +- src/obproxy/utils/ob_proxy_blowfish.cpp | 4 +--- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/obproxy/proxy/mysqllib/ob_2_0_protocol_utils.cpp b/src/obproxy/proxy/mysqllib/ob_2_0_protocol_utils.cpp index 8f8dd07..64be6de 100644 --- a/src/obproxy/proxy/mysqllib/ob_2_0_protocol_utils.cpp +++ b/src/obproxy/proxy/mysqllib/ob_2_0_protocol_utils.cpp @@ -118,8 +118,8 @@ int ObProto20Utils::analyze_one_compressed_packet( int64_t block_len = reader.block_read_avail(); char *buf_start = reader.start(); + char mysql_hdr[MYSQL_COMPRESSED_OB20_HEALDER_LENGTH]; if (OB_UNLIKELY(block_len < MYSQL_COMPRESSED_OB20_HEALDER_LENGTH)) { - char mysql_hdr[MYSQL_COMPRESSED_OB20_HEALDER_LENGTH]; char *written_pos = reader.copy(mysql_hdr, MYSQL_COMPRESSED_OB20_HEALDER_LENGTH, 0); if (OB_UNLIKELY(written_pos != mysql_hdr + MYSQL_COMPRESSED_OB20_HEALDER_LENGTH)) { ret = OB_ERR_UNEXPECTED; diff --git a/src/obproxy/proxy/mysqllib/ob_mysql_analyzer_utils.cpp b/src/obproxy/proxy/mysqllib/ob_mysql_analyzer_utils.cpp index 0502af7..8653f70 100644 --- a/src/obproxy/proxy/mysqllib/ob_mysql_analyzer_utils.cpp +++ b/src/obproxy/proxy/mysqllib/ob_mysql_analyzer_utils.cpp @@ -41,8 +41,8 @@ int ObMysqlAnalyzerUtils::analyze_one_compressed_packet( int64_t block_len = reader.block_read_avail(); char *buf_start = reader.start(); + char mysql_hdr[MYSQL_COMPRESSED_HEALDER_LENGTH]; if (OB_UNLIKELY(block_len < MYSQL_COMPRESSED_HEALDER_LENGTH)) { - char mysql_hdr[MYSQL_COMPRESSED_HEALDER_LENGTH]; char *written_pos = reader.copy(mysql_hdr, MYSQL_COMPRESSED_HEALDER_LENGTH, 0); if (OB_UNLIKELY(written_pos != mysql_hdr + MYSQL_COMPRESSED_HEALDER_LENGTH)) { ret = OB_ERR_UNEXPECTED; diff --git a/src/obproxy/stat/ob_stat_processor.cpp b/src/obproxy/stat/ob_stat_processor.cpp index 87037aa..da5da86 100644 --- a/src/obproxy/stat/ob_stat_processor.cpp +++ b/src/obproxy/stat/ob_stat_processor.cpp @@ -359,7 +359,7 @@ int ObStatProcessor::register_raw_stat( ObRecData data_default; memset(&data_default, 0, sizeof(ObRecData)); - if (OB_UNLIKELY(!check_argument(rsb, id)) || OB_UNLIKELY(sync_type > SYNC_MAX)) { + if (OB_UNLIKELY(!check_argument(rsb, id)) || OB_UNLIKELY(sync_type >= SYNC_MAX)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid rsb or id", K(rsb), K(id), K(sync_type), K(ret)); } else { diff --git a/src/obproxy/utils/ob_proxy_blowfish.cpp b/src/obproxy/utils/ob_proxy_blowfish.cpp index 24a8001..8c31ff7 100644 --- a/src/obproxy/utils/ob_proxy_blowfish.cpp +++ b/src/obproxy/utils/ob_proxy_blowfish.cpp @@ -184,9 +184,7 @@ int ObBlowFish::convert_large_str_to_hex(const char *str, const int64_t str_len, int tmp_value = 0; for(int64_t i = start_pos; out_idx >= padding_len; --out_idx) { if (4 == byte_pos) { - if (i < 0) { - tmp_value = 0; - } else if (i >= int_num) { + if (i >= int_num) { tmp_value = is_negative ? -1 : 0; } else { int32_t var2 = static_cast(mag[int_num - i - 1 + start_pos]); -- GitLab