diff options
author | Damjan Marion <damarion@cisco.com> | 2022-04-04 22:40:45 +0200 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2022-04-04 23:17:13 +0000 |
commit | 8bea589cfe0fca1a6f560e16ca66a4cf199041a2 (patch) | |
tree | cf2767f8f5f31344468b65e14baa3f1a4c85fb91 /src/vlibmemory/socket_client.c | |
parent | a2b358b1faf6e762e1d29a931d83c7735ac9a77d (diff) |
vppinfra: make _vec_len() read-only
Use of _vec_len() to set vector length breaks address sanitizer.
Users should use vec_set_len(), vec_inc_len(), vec_dec_len () instead.
Type: improvement
Change-Id: I441ae948771eb21c23a61f3ff9163bdad74a2cb8
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlibmemory/socket_client.c')
-rw-r--r-- | src/vlibmemory/socket_client.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/vlibmemory/socket_client.c b/src/vlibmemory/socket_client.c index 7082d8ba7e0..237d2224d24 100644 --- a/src/vlibmemory/socket_client.c +++ b/src/vlibmemory/socket_client.c @@ -93,7 +93,7 @@ vl_socket_client_read_internal (socket_client_main_t * scm, int wait) current_rx_index = vec_len (scm->socket_rx_buffer); vec_validate (scm->socket_rx_buffer, current_rx_index + scm->socket_buffer_size - 1); - _vec_len (scm->socket_rx_buffer) = current_rx_index; + vec_set_len (scm->socket_rx_buffer, current_rx_index); n = read (scm->socket_fd, scm->socket_rx_buffer + current_rx_index, scm->socket_buffer_size); if (n < 0) @@ -104,7 +104,7 @@ vl_socket_client_read_internal (socket_client_main_t * scm, int wait) clib_unix_warning ("socket_read"); return -1; } - _vec_len (scm->socket_rx_buffer) += n; + vec_inc_len (scm->socket_rx_buffer, n); } #if CLIB_DEBUG > 1 @@ -116,7 +116,7 @@ vl_socket_client_read_internal (socket_client_main_t * scm, int wait) data_len = ntohl (mbp->data_len); current_rx_index = vec_len (scm->socket_rx_buffer); vec_validate (scm->socket_rx_buffer, current_rx_index + data_len); - _vec_len (scm->socket_rx_buffer) = current_rx_index; + vec_set_len (scm->socket_rx_buffer, current_rx_index); mbp = (msgbuf_t *) (scm->socket_rx_buffer); msg_size = data_len + sizeof (*mbp); @@ -133,7 +133,7 @@ vl_socket_client_read_internal (socket_client_main_t * scm, int wait) clib_unix_warning ("socket_read"); return -1; } - _vec_len (scm->socket_rx_buffer) += n; + vec_inc_len (scm->socket_rx_buffer, n); } if (vec_len (scm->socket_rx_buffer) >= data_len + sizeof (*mbp)) @@ -141,7 +141,7 @@ vl_socket_client_read_internal (socket_client_main_t * scm, int wait) vl_msg_api_socket_handler ((void *) (mbp->data), data_len); if (vec_len (scm->socket_rx_buffer) == data_len + sizeof (*mbp)) - _vec_len (scm->socket_rx_buffer) = 0; + vec_set_len (scm->socket_rx_buffer, 0); else vec_delete (scm->socket_rx_buffer, data_len + sizeof (*mbp), 0); mbp = 0; @@ -480,8 +480,8 @@ vl_socket_client_connect_internal (socket_client_main_t * scm, SOCKET_CLIENT_DEFAULT_BUFFER_SIZE; vec_validate (scm->socket_tx_buffer, scm->socket_buffer_size - 1); vec_validate (scm->socket_rx_buffer, scm->socket_buffer_size - 1); - _vec_len (scm->socket_rx_buffer) = 0; - _vec_len (scm->socket_tx_buffer) = 0; + vec_set_len (scm->socket_rx_buffer, 0); + vec_set_len (scm->socket_tx_buffer, 0); scm->name = format (0, "%s", client_name); mp = vl_socket_client_msg_alloc2 (scm, sizeof (*mp)); |