diff options
author | Marco Varlese <marco.varlese@suse.com> | 2018-04-17 16:41:51 +0200 |
---|---|---|
committer | Marco Varlese <marco.varlese@suse.com> | 2018-04-17 16:49:25 +0200 |
commit | 216c35b2c6e5b4a728675f5141241420841cda34 (patch) | |
tree | 1ec6b8fae7fda39b63eb56ebf14851702f1765e5 /src/vnet/sctp/sctp_input.c | |
parent | 0f4b184757557d2f1221c0df92413381ac4d7c08 (diff) |
SCTP: coverity scan warnings
This patch addresses 182346, 182347, 182353.
Change-Id: I59c3d74bd3a2122b836c93e22ddb632fa032f7fe
Signed-off-by: Marco Varlese <marco.varlese@suse.com>
Diffstat (limited to 'src/vnet/sctp/sctp_input.c')
-rw-r--r-- | src/vnet/sctp/sctp_input.c | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/src/vnet/sctp/sctp_input.c b/src/vnet/sctp/sctp_input.c index bc36a7f91d5..7c753a2ffd7 100644 --- a/src/vnet/sctp/sctp_input.c +++ b/src/vnet/sctp/sctp_input.c @@ -319,8 +319,10 @@ sctp_handle_init (sctp_header_t * sctp_hdr, u16 sctp_implied_length) { sctp_init_chunk_t *init_chunk = (sctp_init_chunk_t *) (sctp_hdr); - ip4_address_t *ip4_addr = 0; - ip6_address_t *ip6_addr = 0; + ip4_address_t ip4_addr; + ip6_address_t ip6_addr; + u8 add_ip4 = 0; + u8 add_ip6 = 0; char hostname[FQDN_MAX_LENGTH]; /* Check the current state of the connection @@ -338,7 +340,7 @@ sctp_handle_init (sctp_header_t * sctp_hdr, SCTP_ADV_DBG ("Received INIT chunk while in COOKIE_WAIT state"); sctp_prepare_initack_chunk_for_collision (sctp_conn, SCTP_PRIMARY_PATH_IDX, - b0, ip4_addr, ip6_addr); + b0, &ip4_addr, &ip6_addr); return SCTP_ERROR_NONE; case SCTP_STATE_COOKIE_ECHOED: case SCTP_STATE_SHUTDOWN_ACK_SENT: @@ -346,11 +348,12 @@ sctp_handle_init (sctp_header_t * sctp_hdr, if (sctp_conn->forming_association_changed == 0) sctp_prepare_initack_chunk_for_collision (sctp_conn, SCTP_PRIMARY_PATH_IDX, - b0, ip4_addr, ip6_addr); + b0, &ip4_addr, + &ip6_addr); else sctp_prepare_abort_for_collision (sctp_conn, SCTP_PRIMARY_PATH_IDX, b0, - ip4_addr, ip6_addr); + &ip4_addr, &ip6_addr); return SCTP_ERROR_NONE; } } @@ -395,13 +398,16 @@ sctp_handle_init (sctp_header_t * sctp_hdr, { sctp_ipv4_addr_param_t *ipv4 = (sctp_ipv4_addr_param_t *) opt_params_hdr; - clib_memcpy (ip4_addr, &ipv4->address, + clib_memcpy (&ip4_addr, &ipv4->address, sizeof (ip4_address_t)); - sctp_sub_connection_add_ip4 (vlib_get_main (), - &sctp_conn->sub_conn - [SCTP_PRIMARY_PATH_IDX].connection. - lcl_ip.ip4, &ipv4->address); + if (sctp_sub_connection_add_ip4 (vlib_get_main (), + &sctp_conn->sub_conn + [SCTP_PRIMARY_PATH_IDX].connection. + lcl_ip.ip4, + &ipv4->address) == + SCTP_ERROR_NONE) + add_ip4 = 1; break; } @@ -409,13 +415,16 @@ sctp_handle_init (sctp_header_t * sctp_hdr, { sctp_ipv6_addr_param_t *ipv6 = (sctp_ipv6_addr_param_t *) opt_params_hdr; - clib_memcpy (ip6_addr, &ipv6->address, + clib_memcpy (&ip6_addr, &ipv6->address, sizeof (ip6_address_t)); - sctp_sub_connection_add_ip6 (vlib_get_main (), - &sctp_conn->sub_conn - [SCTP_PRIMARY_PATH_IDX].connection. - lcl_ip.ip6, &ipv6->address); + if (sctp_sub_connection_add_ip6 (vlib_get_main (), + &sctp_conn->sub_conn + [SCTP_PRIMARY_PATH_IDX].connection. + lcl_ip.ip6, + &ipv6->address) == + SCTP_ERROR_NONE) + add_ip6 = 1; break; } @@ -446,8 +455,8 @@ sctp_handle_init (sctp_header_t * sctp_hdr, } /* Reuse buffer to make init-ack and send */ - sctp_prepare_initack_chunk (sctp_conn, SCTP_PRIMARY_PATH_IDX, b0, ip4_addr, - ip6_addr); + sctp_prepare_initack_chunk (sctp_conn, SCTP_PRIMARY_PATH_IDX, b0, &ip4_addr, + add_ip4, &ip6_addr, add_ip6); return SCTP_ERROR_NONE; } @@ -1695,7 +1704,8 @@ sctp46_listen_process_inline (vlib_main_t * vm, sctp_chunks_common_hdr_t *sctp_chunk_hdr = &full_hdr->common_hdr; u8 chunk_type = vnet_sctp_get_chunk_type (sctp_chunk_hdr); - if (chunk_type != INIT) + if (chunk_type != INIT && chunk_type != DATA + && chunk_type != OPERATION_ERROR) { SCTP_DBG ("conn_index = %u: chunk_type != INIT... chunk_type=%s", |