Merge pull request #10571 from rameshabhinay/ospf6_auth_trailer

ospf6d: fix coverity issues.
This commit is contained in:
Russ White 2022-02-15 13:19:48 -05:00 committed by GitHub
commit c07cfc5494
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 27 deletions

View file

@ -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;
}

View file

@ -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);

View file

@ -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) {

View file

@ -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);

View file

@ -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;