summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss White <russ@riw.us>2022-02-15 13:19:48 -0500
committerGitHub <noreply@github.com>2022-02-15 13:19:48 -0500
commitc07cfc54940c2dce071f5173f0b719592419b2d2 (patch)
tree75ec373ba25194f2ab81683106ce388ba349f3d8
parent8f689a6e8d1370aa1abab79336cedcb283913069 (diff)
parent42bfee18c2484fac611501d6fe047374250ffafc (diff)
Merge pull request #10571 from rameshabhinay/ospf6_auth_trailer
ospf6d: fix coverity issues.
-rw-r--r--lib/keychain.c4
-rw-r--r--lib/keychain.h8
-rw-r--r--ospf6d/ospf6_auth_trailer.c16
-rw-r--r--ospf6d/ospf6_auth_trailer.h2
-rw-r--r--ospf6d/ospf6_message.c21
5 files changed, 24 insertions, 27 deletions
diff --git a/lib/keychain.c b/lib/keychain.c
index 6b03fbd560..c29c45a114 100644
--- a/lib/keychain.c
+++ b/lib/keychain.c
@@ -357,12 +357,12 @@ const struct keychain_algo_info algo_info[] = {
KEYCHAIN_ALGO_MAX_INTERNAL_BLK_SIZE, "Not defined"}
};
-uint32_t keychain_get_block_size(enum keychain_hash_algo key)
+uint16_t keychain_get_block_size(enum keychain_hash_algo key)
{
return algo_info[key].block;
}
-uint32_t keychain_get_hash_len(enum keychain_hash_algo key)
+uint16_t keychain_get_hash_len(enum keychain_hash_algo key)
{
return algo_info[key].length;
}
diff --git a/lib/keychain.h b/lib/keychain.h
index c47bb7a792..71319d9722 100644
--- a/lib/keychain.h
+++ b/lib/keychain.h
@@ -54,14 +54,14 @@ enum keychain_hash_algo {
struct keychain_algo_info {
enum keychain_hash_algo key;
const char *name;
- uint32_t length;
- uint32_t block;
+ uint16_t length;
+ uint16_t block;
const char *desc;
};
extern const struct keychain_algo_info algo_info[];
-uint32_t keychain_get_block_size(enum keychain_hash_algo key);
-uint32_t keychain_get_hash_len(enum keychain_hash_algo key);
+uint16_t keychain_get_block_size(enum keychain_hash_algo key);
+uint16_t keychain_get_hash_len(enum keychain_hash_algo key);
const char *keychain_get_description(enum keychain_hash_algo key);
struct keychain_algo_info
keychain_get_hash_algo_info(enum keychain_hash_algo key);
diff --git a/ospf6d/ospf6_auth_trailer.c b/ospf6d/ospf6_auth_trailer.c
index 5333fdc2f7..1095473f4a 100644
--- a/ospf6d/ospf6_auth_trailer.c
+++ b/ospf6d/ospf6_auth_trailer.c
@@ -82,8 +82,8 @@ const uint8_t ospf6_hash_opad_max[KEYCHAIN_ALGO_MAX_INTERNAL_BLK_SIZE] = {
void ospf6_auth_hdr_dump_send(struct ospf6_header *ospfh, uint16_t length)
{
struct ospf6_auth_hdr *ospf6_at_hdr;
- int at_len, oh_len, at_hdr_len, hash_len;
- unsigned char temp[KEYCHAIN_MAX_HASH_SIZE+1];
+ uint16_t at_len, oh_len, at_hdr_len, hash_len;
+ unsigned char temp[KEYCHAIN_MAX_HASH_SIZE + 1];
oh_len = htons(ospfh->length);
at_len = length - oh_len;
@@ -111,7 +111,7 @@ void ospf6_auth_hdr_dump_recv(struct ospf6_header *ospfh, uint16_t length,
unsigned int lls_len)
{
struct ospf6_auth_hdr *ospf6_at_hdr;
- int at_len, oh_len, at_hdr_len, hash_len;
+ uint16_t at_len, oh_len, at_hdr_len, hash_len;
unsigned char temp[KEYCHAIN_MAX_HASH_SIZE + 1];
oh_len = ntohs(ospfh->length);
@@ -246,7 +246,7 @@ static void ospf6_hash_hmac_sha_digest(enum keychain_hash_algo key,
unsigned char *mes, uint32_t len,
unsigned char *digest)
{
- if ((key <= KEYCHAIN_ALGO_NULL) || (key >= KEYCHAIN_ALGO_MAX))
+ if ((key < KEYCHAIN_ALGO_NULL) || (key > KEYCHAIN_ALGO_MAX))
return;
switch (key) {
@@ -279,9 +279,9 @@ static void ospf6_hash_hmac_sha_digest(enum keychain_hash_algo key,
}
}
-unsigned int ospf6_auth_len_get(struct ospf6_interface *oi)
+uint16_t ospf6_auth_len_get(struct ospf6_interface *oi)
{
- unsigned int at_len = 0;
+ uint16_t at_len = 0;
char *keychain_name = NULL;
struct keychain *keychain = NULL;
struct key *key = NULL;
@@ -481,8 +481,8 @@ int ospf6_auth_check_digest(struct ospf6_header *oh, struct ospf6_interface *oi,
if (oi->at_data.flags == 0)
return OSPF6_AUTH_PROCESS_NORMAL;
- ospf6_auth = (struct ospf6_auth_hdr *)((uint8_t *)oh + oh_len
- + lls_block_len);
+ ospf6_auth = (struct ospf6_auth_hdr *)((uint8_t *)oh +
+ (oh_len + lls_block_len));
if (CHECK_FLAG(oi->at_data.flags, OSPF6_AUTH_TRAILER_KEYCHAIN)) {
keychain = keychain_lookup(oi->at_data.keychain);
if (!keychain) {
diff --git a/ospf6d/ospf6_auth_trailer.h b/ospf6d/ospf6_auth_trailer.h
index 86ec49beba..dea4a6e168 100644
--- a/ospf6d/ospf6_auth_trailer.h
+++ b/ospf6d/ospf6_auth_trailer.h
@@ -70,7 +70,7 @@ void ospf6_auth_hdr_dump_recv(struct ospf6_header *ospfh, uint16_t length,
unsigned int lls_len);
unsigned char *ospf6_hash_message_xor(unsigned char *mes1, unsigned char *mes2,
uint32_t len);
-unsigned int ospf6_auth_len_get(struct ospf6_interface *oi);
+uint16_t ospf6_auth_len_get(struct ospf6_interface *oi);
int ospf6_auth_validate_pkt(struct ospf6_interface *oi, unsigned int *pkt_len,
struct ospf6_header *oh, unsigned int *at_len,
unsigned int *lls_block_len);
diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c
index c1004a7080..7ebfdd26e1 100644
--- a/ospf6d/ospf6_message.c
+++ b/ospf6d/ospf6_message.c
@@ -2021,9 +2021,9 @@ static void ospf6_auth_trailer_copy_keychain_key(struct ospf6_interface *oi)
}
}
-static uint32_t ospf6_packet_max(struct ospf6_interface *oi)
+static uint16_t ospf6_packet_max(struct ospf6_interface *oi)
{
- int at_len = 0;
+ uint16_t at_len = 0;
assert(oi->ifmtu > sizeof(struct ip6_hdr));
@@ -2092,7 +2092,7 @@ static int ospf6_write(struct thread *thread)
int len;
int64_t latency = 0;
struct timeval timestamp;
- unsigned int at_len = 0;
+ uint16_t at_len = 0;
if (ospf6->fd < 0) {
zlog_warn("ospf6_write failed to send, fd %d", ospf6->fd);
@@ -2621,9 +2621,8 @@ static uint16_t ospf6_make_lsupdate_list(struct ospf6_neighbor *on,
stream_forward_endp((*op)->s, OSPF6_LS_UPD_MIN_SIZE);
for (ALL_LSDB(on->lsupdate_list, lsa, lsanext)) {
- if ((length + (unsigned int)OSPF6_LSA_SIZE(lsa->header)
- + OSPF6_HEADER_SIZE)
- > ospf6_packet_max(on->ospf6_if)) {
+ if ((length + OSPF6_LSA_SIZE(lsa->header) + OSPF6_HEADER_SIZE) >
+ ospf6_packet_max(on->ospf6_if)) {
ospf6_fill_header(on->ospf6_if, (*op)->s,
length + OSPF6_HEADER_SIZE);
(*op)->length = length + OSPF6_HEADER_SIZE;
@@ -2659,9 +2658,8 @@ static uint16_t ospf6_make_ls_retrans_list(struct ospf6_neighbor *on,
stream_forward_endp((*op)->s, OSPF6_LS_UPD_MIN_SIZE);
for (ALL_LSDB(on->retrans_list, lsa, lsanext)) {
- if ((length + (unsigned int)OSPF6_LSA_SIZE(lsa->header)
- + OSPF6_HEADER_SIZE)
- > ospf6_packet_max(on->ospf6_if)) {
+ if ((length + OSPF6_LSA_SIZE(lsa->header) + OSPF6_HEADER_SIZE) >
+ ospf6_packet_max(on->ospf6_if)) {
ospf6_fill_header(on->ospf6_if, (*op)->s,
length + OSPF6_HEADER_SIZE);
(*op)->length = length + OSPF6_HEADER_SIZE;
@@ -2800,9 +2798,8 @@ static uint16_t ospf6_make_lsupdate_interface(struct ospf6_interface *oi,
stream_forward_endp((*op)->s, OSPF6_LS_UPD_MIN_SIZE);
for (ALL_LSDB(oi->lsupdate_list, lsa, lsanext)) {
- if (length + (unsigned int)OSPF6_LSA_SIZE(lsa->header)
- + OSPF6_HEADER_SIZE
- > ospf6_packet_max(oi)) {
+ if (length + OSPF6_LSA_SIZE(lsa->header) + OSPF6_HEADER_SIZE >
+ ospf6_packet_max(oi)) {
ospf6_fill_header(oi, (*op)->s,
length + OSPF6_HEADER_SIZE);
(*op)->length = length + OSPF6_HEADER_SIZE;