Skip to content

Commit

Permalink
sctp: store cookie secret change time as time_t
Browse files Browse the repository at this point in the history
Reported by:	Coverity Scan
CID:		1492349
CID:		1493281
MFC after:	3 days
  • Loading branch information
tuexen committed May 10, 2024
1 parent 0b272e0 commit 9d8a371
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions sys/netinet/sctp_input.c
Expand Up @@ -2329,7 +2329,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset,
}
ep = &(*inp_p)->sctp_ep;
/* which cookie is it? */
if ((cookie->time_entered.tv_sec < (long)ep->time_of_secret_change) &&
if ((cookie->time_entered.tv_sec < ep->time_of_secret_change) &&
(ep->current_secret_number != ep->last_secret_number)) {
/* it's the old cookie */
(void)sctp_hmac_m(SCTP_HMAC,
Expand All @@ -2352,7 +2352,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset,
/* compare the received digest with the computed digest */
if (timingsafe_bcmp(calc_sig, sig, SCTP_SIGNATURE_SIZE) != 0) {
/* try the old cookie? */
if ((cookie->time_entered.tv_sec == (long)ep->time_of_secret_change) &&
if ((cookie->time_entered.tv_sec == ep->time_of_secret_change) &&
(ep->current_secret_number != ep->last_secret_number)) {
/* compute digest with old */
(void)sctp_hmac_m(SCTP_HMAC,
Expand Down
2 changes: 1 addition & 1 deletion sys/netinet/sctp_pcb.c
Expand Up @@ -2570,7 +2570,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id)

/* Setup the initial secret */
(void)SCTP_GETTIME_TIMEVAL(&time);
m->time_of_secret_change = (unsigned int)time.tv_sec;
m->time_of_secret_change = time.tv_sec;

for (i = 0; i < SCTP_NUMBER_OF_SECRETS; i++) {
m->secret_key[0][i] = sctp_select_initial_TSN(m);
Expand Down
4 changes: 2 additions & 2 deletions sys/netinet/sctp_pcb.h
Expand Up @@ -263,8 +263,8 @@ struct sctp_base_info {
* access /dev/random.
*/
struct sctp_pcb {
unsigned int time_of_secret_change; /* number of seconds from
* timeval.tv_sec */
time_t time_of_secret_change; /* number of seconds from
* timeval.tv_sec */
uint32_t secret_key[SCTP_HOW_MANY_SECRETS][SCTP_NUMBER_OF_SECRETS];
unsigned int size_of_a_cookie;

Expand Down
2 changes: 1 addition & 1 deletion sys/netinet/sctputil.c
Expand Up @@ -1944,7 +1944,7 @@ sctp_timeout_handler(void *t)
type, inp, stcb, net));
SCTP_STAT_INCR(sctps_timosecret);
(void)SCTP_GETTIME_TIMEVAL(&tv);
inp->sctp_ep.time_of_secret_change = (unsigned int)tv.tv_sec;
inp->sctp_ep.time_of_secret_change = tv.tv_sec;
inp->sctp_ep.last_secret_number =
inp->sctp_ep.current_secret_number;
inp->sctp_ep.current_secret_number++;
Expand Down

0 comments on commit 9d8a371

Please sign in to comment.