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

Fix coverity warning #4003

Merged
merged 3 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion pjlib/src/pjlib-test/ioq_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ static int compliance_test_2(const pj_ioqueue_cfg *cfg)
if (client[i].key != NULL) {
pj_ioqueue_unregister(client[i].key);
client[i].key = NULL;
server[i].sock = PJ_INVALID_SOCKET;
client[i].sock = PJ_INVALID_SOCKET;
} else if (client[i].sock != PJ_INVALID_SOCKET) {
pj_sock_close(client[i].sock);
client[i].sock = PJ_INVALID_SOCKET;
Expand Down
6 changes: 4 additions & 2 deletions pjmedia/src/pjmedia/endpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,8 +803,10 @@ pjmedia_endpt_create_video_sdp(pjmedia_endpt *endpt,
continue;
}

pjmedia_vid_codec_mgr_get_default_param(NULL, &codec_info[i],
&codec_param);
status = pjmedia_vid_codec_mgr_get_default_param(NULL, &codec_info[i],
&codec_param);
if (status != PJ_SUCCESS)
return status;

fmt = &m->desc.fmt[m->desc.fmt_count++];
fmt->ptr = (char*) pj_pool_alloc(pool, 8);
Expand Down
2 changes: 1 addition & 1 deletion pjmedia/src/pjmedia/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -2895,7 +2895,7 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt,
pj_sockaddr_cp(&stream->rem_rtp_addr, &info->rem_addr);
if (stream->si.rtcp_mux) {
pj_sockaddr_cp(&att_param.rem_rtcp, &info->rem_addr);
} else if (pj_sockaddr_has_addr(&info->rem_rtcp.addr)) {
} else if (pj_sockaddr_has_addr(&info->rem_rtcp)) {
pj_sockaddr_cp(&att_param.rem_rtcp, &info->rem_rtcp);
}
att_param.addr_len = pj_sockaddr_get_len(&info->rem_addr);
Expand Down
2 changes: 1 addition & 1 deletion pjmedia/src/pjmedia/vid_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -2044,7 +2044,7 @@ PJ_DEF(pj_status_t) pjmedia_vid_stream_create(
pj_sockaddr_cp(&stream->rem_rtp_addr, &info->rem_addr);
if (info->rtcp_mux) {
pj_sockaddr_cp(&att_param.rem_rtcp, &info->rem_addr);
} else if (pj_sockaddr_has_addr(&info->rem_rtcp.addr)) {
} else if (pj_sockaddr_has_addr(&info->rem_rtcp)) {
pj_sockaddr_cp(&att_param.rem_rtcp, &info->rem_rtcp);
}
att_param.addr_len = pj_sockaddr_get_len(&info->rem_addr);
Expand Down
6 changes: 6 additions & 0 deletions pjsip/src/pjsip-ua/sip_100rel.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,12 @@ PJ_DEF(pj_status_t) pjsip_100rel_create_prack( pjsip_inv_session *inv,
}
rseq = (pj_uint32_t) pj_strtoul(&rseq_hdr->hvalue);

if (rseq < 1) {
PJ_LOG(4, (dd->inv->dlg->obj_name,
"Ignoring 100rel response RSeq header value less than 1"));
return PJSIP_EINVALIDMSG;
}

Copy link
Member

Choose a reason for hiding this comment

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

Actually as receiver, we better be lenient, especially if it is not so urgent/risky, perhaps printing warning is sufficient?

Copy link
Member Author

Choose a reason for hiding this comment

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

If the message received with RSeq 0, currently it will be ignored in https://github.com/pjsip/pjproject/blob/coverity02/pjsip/src/pjsip-ua/sip_100rel.c#L303

Copy link
Member

Choose a reason for hiding this comment

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

so should we return PJ_EIGNORED here, so it's the same as the old behavior?

Copy link
Member

Choose a reason for hiding this comment

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

If the message received with RSeq 0, currently it will be ignored in https://github.com/pjsip/pjproject/blob/coverity02/pjsip/src/pjsip-ua/sip_100rel.c#L303

The pointed code does not seem to check for rseq==0, it checks for retransmission (where the original rseq may still be 0)? So IMO, perhaps better check the behavior when rseq ==0 (e.g: using SIPp) to at least avoid behavior change.

Copy link
Member Author

Choose a reason for hiding this comment

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

The rseq is unsigned, so the condition will always be true when rseq ==0 regardless the original rseq. If we want to avoid behavior change we should return PJ_EIGNORED (as @sauwming suggested) or just print the warning message.

/* Find UAC state for the specified call leg */
uac_state = dd->uac_state_list;
while (uac_state) {
Expand Down
Loading