Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverity 2024 new hotness #17865

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions bgpd/bgp_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,9 @@ static void bgp_holdtime_timer(struct event *thread)
* for systems where we are heavily loaded for one
* reason or another.
*/
inq_count = atomic_load_explicit(&connection->ibuf->count,
memory_order_relaxed);
frr_with_mutex (&connection->io_mtx) {
inq_count = atomic_load_explicit(&connection->ibuf->count, memory_order_relaxed);
}
if (inq_count)
BGP_TIMER_ON(connection->t_holdtime, bgp_holdtime_timer,
peer->v_holdtime);
Expand Down
18 changes: 18 additions & 0 deletions ospfd/ospf_api.c
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this will get rid of the SA errors. However, is there a reason you just didn't change the OSPF_API_MAX_MSG_SIZE to UINT16_MAX? The struct msg length limits it to that anyway,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know that there was a OSPF_API_MAX_MSG_SIZE. Let me look at that .

Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,12 @@ struct msg *new_msg_originate_request(uint32_t seqnum, struct in_addr ifaddr,
omsglen += sizeof(struct msg_originate_request)
- sizeof(struct lsa_header);

if (omsglen > UINT16_MAX) {
zlog_warn("%s: LSA specified is bigger than maximum LSA size, something is wrong",
__func__);
omsglen = UINT16_MAX;
}

return msg_new(MSG_ORIGINATE_REQUEST, omsg, seqnum, omsglen);
}

Expand Down Expand Up @@ -639,6 +645,12 @@ struct msg *new_msg_lsa_change_notify(uint8_t msgtype, uint32_t seqnum,
memcpy(nmsg_data, data, len);
len += sizeof(struct msg_lsa_change_notify) - sizeof(struct lsa_header);

if (len > UINT16_MAX) {
zlog_warn("%s: LSA specified is bigger than maximum LSA size, something is wrong",
__func__);
len = UINT16_MAX;
}

return msg_new(msgtype, nmsg, seqnum, len);
}

Expand Down Expand Up @@ -666,6 +678,12 @@ struct msg *new_msg_reachable_change(uint32_t seqnum, uint16_t nadd,
nmsg->nremove = htons(nremove);
len = sizeof(*nmsg) + insz * (nadd + nremove);

if (len > UINT16_MAX) {
zlog_warn("%s: LSA specified is bigger than maximum LSA size, something is wrong",
__func__);
len = UINT16_MAX;
}

return msg_new(MSG_REACHABLE_CHANGE, nmsg, seqnum, len);
}

Expand Down
5 changes: 4 additions & 1 deletion zebra/zebra_dplane.c
Original file line number Diff line number Diff line change
Expand Up @@ -7698,7 +7698,10 @@ static void zebra_dplane_init_internal(void)

dplane_prov_list_init(&zdplane_info.dg_providers);

dplane_ctx_list_init(&zdplane_info.dg_update_list);
frr_with_mutex (&zdplane_info.dg_mutex) {
dplane_ctx_list_init(&zdplane_info.dg_update_list);
}

zns_info_list_init(&zdplane_info.dg_zns_list);

zdplane_info.dg_updates_per_cycle = DPLANE_DEFAULT_NEW_WORK;
Expand Down
4 changes: 4 additions & 0 deletions zebra/zserv.c
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,10 @@ void zserv_close(void)
/*
* Open zebra's ZAPI listener socket. This is done early during startup,
* before zebra is ready to listen and accept client connections.
*
* This function should only ever be called from the startup pthread
* from main.c. If it is called multiple times it will cause problems
* because it causes the zsock global variable to be setup.
*/
void zserv_open(const char *path)
{
Expand Down
3 changes: 3 additions & 0 deletions zebra/zserv.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ extern void zserv_close(void);
*
* path
* where to place the Unix domain socket
*
* This function *should* only ever be called from
* main() and only every from 1 pthread.
*/
extern void zserv_open(const char *path);

Expand Down
Loading