project
stringclasses
633 values
commit_id
stringlengths
7
81
target
int64
0
1
func
stringlengths
5
484k
cwe
stringclasses
131 values
big_vul_idx
float64
0
189k
idx
int64
0
522k
hash
stringlengths
34
39
size
float64
1
24k
message
stringlengths
0
11.5k
dataset
stringclasses
1 value
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_handle_read_header_done(void *opaque) { RedLinkInfo *link = (RedLinkInfo *)opaque; SpiceLinkHeader *header = &link->link_header; AsyncRead *obj = &link->async_read; if (header->magic != SPICE_MAGIC) { reds_send_link_error(link, SPICE_LINK_ERR_INVALID_MAGIC); reds_link_free(link); return; } if (header->major_version != SPICE_VERSION_MAJOR) { if (header->major_version > 0) { reds_send_link_error(link, SPICE_LINK_ERR_VERSION_MISMATCH); } spice_warning("version mismatch"); reds_link_free(link); return; } reds->peer_minor_version = header->minor_version; if (header->size < sizeof(SpiceLinkMess)) { reds_send_link_error(link, SPICE_LINK_ERR_INVALID_DATA); spice_warning("bad size %u", header->size); reds_link_free(link); return; } link->link_mess = spice_malloc(header->size); obj->now = (uint8_t *)link->link_mess; obj->end = obj->now + header->size; obj->done = reds_handle_read_link_done; async_read_handler(0, 0, &link->async_read); }
CWE-119
1,883
12,305
12177488769661623890833882003442447221
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_handle_read_link_done(void *opaque) { RedLinkInfo *link = (RedLinkInfo *)opaque; SpiceLinkMess *link_mess = link->link_mess; AsyncRead *obj = &link->async_read; uint32_t num_caps = link_mess->num_common_caps + link_mess->num_channel_caps; uint32_t *caps = (uint32_t *)((uint8_t *)link_mess + link_mess->caps_offset); int auth_selection; if (num_caps && (num_caps * sizeof(uint32_t) + link_mess->caps_offset > link->link_header.size || link_mess->caps_offset < sizeof(*link_mess))) { reds_send_link_error(link, SPICE_LINK_ERR_INVALID_DATA); reds_link_free(link); return; } auth_selection = test_capabilty(caps, link_mess->num_common_caps, SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION); if (!reds_security_check(link)) { if (link->stream->ssl) { spice_warning("spice channels %d should not be encrypted", link_mess->channel_type); reds_send_link_error(link, SPICE_LINK_ERR_NEED_UNSECURED); } else { spice_warning("spice channels %d should be encrypted", link_mess->channel_type); reds_send_link_error(link, SPICE_LINK_ERR_NEED_SECURED); } reds_link_free(link); return; } if (!reds_send_link_ack(link)) { reds_link_free(link); return; } if (!auth_selection) { if (sasl_enabled && !link->skip_auth) { spice_warning("SASL enabled, but peer supports only spice authentication"); reds_send_link_error(link, SPICE_LINK_ERR_VERSION_MISMATCH); return; } spice_warning("Peer doesn't support AUTH selection"); reds_get_spice_ticket(link); } else { obj->now = (uint8_t *)&link->auth_mechanism; obj->end = obj->now + sizeof(SpiceLinkAuthMechanism); obj->done = reds_handle_auth_mechanism; async_read_handler(0, 0, &link->async_read); } }
CWE-119
1,884
12,306
95217523403386517198776545025402100686
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_handle_ssl_accept(int fd, int event, void *data) { RedLinkInfo *link = (RedLinkInfo *)data; int return_code; if ((return_code = SSL_accept(link->stream->ssl)) != 1) { int ssl_error = SSL_get_error(link->stream->ssl, return_code); if (ssl_error != SSL_ERROR_WANT_READ && ssl_error != SSL_ERROR_WANT_WRITE) { spice_warning("SSL_accept failed, error=%d", ssl_error); reds_link_free(link); } else { if (ssl_error == SSL_ERROR_WANT_READ) { core->watch_update_mask(link->stream->watch, SPICE_WATCH_EVENT_READ); } else { core->watch_update_mask(link->stream->watch, SPICE_WATCH_EVENT_WRITE); } } return; } reds_stream_remove_watch(link->stream); reds_handle_new_link(link); }
CWE-119
1,885
12,307
150051238563088301885279936439599322477
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
int reds_has_vdagent(void) { return !!vdagent; }
CWE-119
1,886
12,308
61250574637453079200699146883090114446
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_info_new_channel(RedLinkInfo *link, int connection_id) { spice_info("channel %d:%d, connected successfully, over %s link", link->link_mess->channel_type, link->link_mess->channel_id, link->stream->ssl == NULL ? "Non Secure" : "Secure"); /* add info + send event */ if (link->stream->ssl) { link->stream->info->flags |= SPICE_CHANNEL_EVENT_FLAG_TLS; } link->stream->info->connection_id = connection_id; link->stream->info->type = link->link_mess->channel_type; link->stream->info->id = link->link_mess->channel_id; reds_stream_push_channel_event(link->stream, SPICE_CHANNEL_EVENT_INITIALIZED); }
CWE-119
1,887
12,309
333726455128359663110096907619664197503
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static RedLinkInfo *reds_init_client_connection(int socket) { RedLinkInfo *link; RedsStream *stream; int delay_val = 1; int flags; if ((flags = fcntl(socket, F_GETFL)) == -1) { spice_warning("accept failed, %s", strerror(errno)); goto error; } if (fcntl(socket, F_SETFL, flags | O_NONBLOCK) == -1) { spice_warning("accept failed, %s", strerror(errno)); goto error; } if (setsockopt(socket, IPPROTO_TCP, TCP_NODELAY, &delay_val, sizeof(delay_val)) == -1) { if (errno != ENOTSUP) { spice_warning("setsockopt failed, %s", strerror(errno)); } } link = spice_new0(RedLinkInfo, 1); stream = spice_new0(RedsStream, 1); stream->info = spice_new0(SpiceChannelEventInfo, 1); link->stream = stream; stream->socket = socket; /* gather info + send event */ /* deprecated fields. Filling them for backward compatibility */ stream->info->llen = sizeof(stream->info->laddr); stream->info->plen = sizeof(stream->info->paddr); getsockname(stream->socket, (struct sockaddr*)(&stream->info->laddr), &stream->info->llen); getpeername(stream->socket, (struct sockaddr*)(&stream->info->paddr), &stream->info->plen); stream->info->flags |= SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT; stream->info->llen_ext = sizeof(stream->info->laddr_ext); stream->info->plen_ext = sizeof(stream->info->paddr_ext); getsockname(stream->socket, (struct sockaddr*)(&stream->info->laddr_ext), &stream->info->llen_ext); getpeername(stream->socket, (struct sockaddr*)(&stream->info->paddr_ext), &stream->info->plen_ext); reds_stream_push_channel_event(stream, SPICE_CHANNEL_EVENT_CONNECTED); openssl_init(link); return link; error: return NULL; }
CWE-119
1,888
12,310
194765804769429747664763022294665299780
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static RedLinkInfo *reds_init_client_ssl_connection(int socket) { RedLinkInfo *link; int return_code; int ssl_error; BIO *sbio; link = reds_init_client_connection(socket); if (link == NULL) goto error; if (!(sbio = BIO_new_socket(link->stream->socket, BIO_NOCLOSE))) { spice_warning("could not allocate ssl bio socket"); goto error; } link->stream->ssl = SSL_new(reds->ctx); if (!link->stream->ssl) { spice_warning("could not allocate ssl context"); BIO_free(sbio); goto error; } SSL_set_bio(link->stream->ssl, sbio, sbio); link->stream->write = stream_ssl_write_cb; link->stream->read = stream_ssl_read_cb; link->stream->writev = NULL; return_code = SSL_accept(link->stream->ssl); if (return_code == 1) { reds_handle_new_link(link); return link; } ssl_error = SSL_get_error(link->stream->ssl, return_code); if (return_code == -1 && (ssl_error == SSL_ERROR_WANT_READ || ssl_error == SSL_ERROR_WANT_WRITE)) { int eventmask = ssl_error == SSL_ERROR_WANT_READ ? SPICE_WATCH_EVENT_READ : SPICE_WATCH_EVENT_WRITE; link->stream->watch = core->watch_add(link->stream->socket, eventmask, reds_handle_ssl_accept, link); return link; } ERR_print_errors_fp(stderr); spice_warning("SSL_accept failed, error=%d", ssl_error); SSL_free(link->stream->ssl); error: free(link->stream); BN_free(link->tiTicketing.bn); free(link); return NULL; }
CWE-119
1,889
12,311
234554348981118028922775011038348457538
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static int reds_init_net(void) { if (spice_port != -1) { reds->listen_socket = reds_init_socket(spice_addr, spice_port, spice_family); if (-1 == reds->listen_socket) { return -1; } reds->listen_watch = core->watch_add(reds->listen_socket, SPICE_WATCH_EVENT_READ, reds_accept, NULL); if (reds->listen_watch == NULL) { spice_warning("set fd handle failed"); return -1; } } if (spice_secure_port != -1) { reds->secure_listen_socket = reds_init_socket(spice_addr, spice_secure_port, spice_family); if (-1 == reds->secure_listen_socket) { return -1; } reds->secure_listen_watch = core->watch_add(reds->secure_listen_socket, SPICE_WATCH_EVENT_READ, reds_accept_ssl_connection, NULL); if (reds->secure_listen_watch == NULL) { spice_warning("set fd handle failed"); return -1; } } if (spice_listen_socket_fd != -1 ) { reds->listen_socket = spice_listen_socket_fd; reds->listen_watch = core->watch_add(reds->listen_socket, SPICE_WATCH_EVENT_READ, reds_accept, NULL); if (reds->listen_watch == NULL) { spice_warning("set fd handle failed"); return -1; } } return 0; }
CWE-119
1,890
12,312
147135263636513972338736905897729312290
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static int reds_init_ssl(void) { #if OPENSSL_VERSION_NUMBER >= 0x10000000L const SSL_METHOD *ssl_method; #else SSL_METHOD *ssl_method; #endif int return_code; long ssl_options = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3; /* Global system initialization*/ SSL_library_init(); SSL_load_error_strings(); /* Create our context*/ ssl_method = TLSv1_method(); reds->ctx = SSL_CTX_new(ssl_method); if (!reds->ctx) { spice_warning("Could not allocate new SSL context"); return -1; } /* Limit connection to TLSv1 only */ #ifdef SSL_OP_NO_COMPRESSION ssl_options |= SSL_OP_NO_COMPRESSION; #endif SSL_CTX_set_options(reds->ctx, ssl_options); /* Load our keys and certificates*/ return_code = SSL_CTX_use_certificate_chain_file(reds->ctx, ssl_parameters.certs_file); if (return_code == 1) { spice_info("Loaded certificates from %s", ssl_parameters.certs_file); } else { spice_warning("Could not load certificates from %s", ssl_parameters.certs_file); return -1; } SSL_CTX_set_default_passwd_cb(reds->ctx, ssl_password_cb); return_code = SSL_CTX_use_PrivateKey_file(reds->ctx, ssl_parameters.private_key_file, SSL_FILETYPE_PEM); if (return_code == 1) { spice_info("Using private key from %s", ssl_parameters.private_key_file); } else { spice_warning("Could not use private key file"); return -1; } /* Load the CAs we trust*/ return_code = SSL_CTX_load_verify_locations(reds->ctx, ssl_parameters.ca_certificate_file, 0); if (return_code == 1) { spice_info("Loaded CA certificates from %s", ssl_parameters.ca_certificate_file); } else { spice_warning("Could not use CA file %s", ssl_parameters.ca_certificate_file); return -1; } #if (OPENSSL_VERSION_NUMBER < 0x00905100L) SSL_CTX_set_verify_depth(reds->ctx, 1); #endif if (strlen(ssl_parameters.dh_key_file) > 0) { if (load_dh_params(reds->ctx, ssl_parameters.dh_key_file) < 0) { return -1; } } SSL_CTX_set_session_id_context(reds->ctx, (const unsigned char *)"SPICE", 5); if (strlen(ssl_parameters.ciphersuite) > 0) { if (!SSL_CTX_set_cipher_list(reds->ctx, ssl_parameters.ciphersuite)) { return -1; } } openssl_thread_setup(); #ifndef SSL_OP_NO_COMPRESSION STACK *cmp_stack = SSL_COMP_get_compression_methods(); sk_zero(cmp_stack); #endif return 0; }
CWE-119
1,891
12,313
183141513247355284140244494745627790432
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_link_free(RedLinkInfo *link) { reds_stream_free(link->stream); link->stream = NULL; free(link->link_mess); link->link_mess = NULL; BN_free(link->tiTicketing.bn); link->tiTicketing.bn = NULL; if (link->tiTicketing.rsa) { RSA_free(link->tiTicketing.rsa); link->tiTicketing.rsa = NULL; } free(link); }
CWE-119
1,892
12,314
100064932290032494880569775900256992441
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static int reds_link_mig_target_channels(RedClient *client) { RedsMigTargetClient *mig_client; RingItem *item; spice_info("%p", client); mig_client = reds_mig_target_client_find(client); if (!mig_client) { spice_info("Error: mig target client was not found"); return FALSE; } /* Each channel should check if we are during migration, and * act accordingly. */ RING_FOREACH(item, &mig_client->pending_links) { RedsMigPendingLink *mig_link; RedChannel *channel; mig_link = SPICE_CONTAINEROF(item, RedsMigPendingLink, ring_link); channel = reds_find_channel(mig_link->link_msg->channel_type, mig_link->link_msg->channel_id); if (!channel) { spice_warning("client %p channel (%d, %d) (type, id) wasn't found", client, mig_link->link_msg->channel_type, mig_link->link_msg->channel_id); continue; } reds_channel_do_link(channel, client, mig_link->link_msg, mig_link->stream); } reds_mig_target_client_free(mig_client); return TRUE; }
CWE-119
1,893
12,315
57158108180204058141919564299177340303
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static int reds_main_channel_connected(void) { return main_channel_is_connected(reds->main_channel); }
CWE-119
1,894
12,316
310663762080715031309115582379528579741
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
void reds_marshall_migrate_data(SpiceMarshaller *m) { SpiceMigrateDataMain mig_data; VDIPortState *agent_state = &reds->agent_state; SpiceMarshaller *m2; memset(&mig_data, 0, sizeof(mig_data)); spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_MAIN_MAGIC); spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_MAIN_VERSION); if (!vdagent) { uint8_t *null_agent_mig_data; spice_assert(!agent_state->base); /* MSG_AGENT_CONNECTED_TOKENS is supported by the client (see spice_server_migrate_connect), so SpiceCharDeviceState is destroyed when the agent is disconnected and there is no need to track the client tokens (see reds_reset_vdp) */ spice_char_device_state_migrate_data_marshall_empty(m); null_agent_mig_data = spice_marshaller_reserve_space(m, sizeof(SpiceMigrateDataMain) - sizeof(SpiceMigrateDataCharDevice)); memset(null_agent_mig_data, 0, sizeof(SpiceMigrateDataMain) - sizeof(SpiceMigrateDataCharDevice)); return; } spice_char_device_state_migrate_data_marshall(reds->agent_state.base, m); spice_marshaller_add_uint8(m, reds->agent_state.client_agent_started); mig_data.agent2client.chunk_header = agent_state->vdi_chunk_header; /* agent to client partial msg */ if (agent_state->read_state == VDI_PORT_READ_STATE_READ_HEADER) { mig_data.agent2client.chunk_header_size = agent_state->receive_pos - (uint8_t *)&agent_state->vdi_chunk_header; mig_data.agent2client.msg_header_done = FALSE; mig_data.agent2client.msg_header_partial_len = 0; spice_assert(!agent_state->read_filter.msg_data_to_read); } else { mig_data.agent2client.chunk_header_size = sizeof(VDIChunkHeader); mig_data.agent2client.chunk_header.size = agent_state->message_receive_len; if (agent_state->read_state == VDI_PORT_READ_STATE_READ_DATA) { /* in the middle of reading the message header (see reds_on_main_channel_migrate) */ mig_data.agent2client.msg_header_done = FALSE; mig_data.agent2client.msg_header_partial_len = agent_state->receive_pos - agent_state->current_read_buf->data; spice_assert(mig_data.agent2client.msg_header_partial_len < sizeof(VDAgentMessage)); spice_assert(!agent_state->read_filter.msg_data_to_read); } else { mig_data.agent2client.msg_header_done = TRUE; mig_data.agent2client.msg_remaining = agent_state->read_filter.msg_data_to_read; mig_data.agent2client.msg_filter_result = agent_state->read_filter.result; } } spice_marshaller_add_uint32(m, mig_data.agent2client.chunk_header_size); spice_marshaller_add(m, (uint8_t *)&mig_data.agent2client.chunk_header, sizeof(VDIChunkHeader)); spice_marshaller_add_uint8(m, mig_data.agent2client.msg_header_done); spice_marshaller_add_uint32(m, mig_data.agent2client.msg_header_partial_len); m2 = spice_marshaller_get_ptr_submarshaller(m, 0); spice_marshaller_add(m2, agent_state->current_read_buf->data, mig_data.agent2client.msg_header_partial_len); spice_marshaller_add_uint32(m, mig_data.agent2client.msg_remaining); spice_marshaller_add_uint8(m, mig_data.agent2client.msg_filter_result); mig_data.client2agent.msg_remaining = agent_state->write_filter.msg_data_to_read; mig_data.client2agent.msg_filter_result = agent_state->write_filter.result; spice_marshaller_add_uint32(m, mig_data.client2agent.msg_remaining); spice_marshaller_add_uint8(m, mig_data.client2agent.msg_filter_result); spice_debug("from agent filter: discard all %d, wait_msg %u, msg_filter_result %d", agent_state->read_filter.discard_all, agent_state->read_filter.msg_data_to_read, agent_state->read_filter.result); spice_debug("to agent filter: discard all %d, wait_msg %u, msg_filter_result %d", agent_state->write_filter.discard_all, agent_state->write_filter.msg_data_to_read, agent_state->write_filter.result); }
CWE-119
1,895
12,317
223996550799081422954338708145848062276
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_mig_cleanup(void) { if (reds->mig_inprogress) { if (reds->mig_wait_connect || reds->mig_wait_disconnect) { SpiceMigrateInterface *sif; spice_assert(migration_interface); sif = SPICE_CONTAINEROF(migration_interface->base.sif, SpiceMigrateInterface, base); if (reds->mig_wait_connect) { sif->migrate_connect_complete(migration_interface); } else { if (sif->migrate_end_complete) { sif->migrate_end_complete(migration_interface); } } } reds->mig_inprogress = FALSE; reds->mig_wait_connect = FALSE; reds->mig_wait_disconnect = FALSE; core->timer_cancel(reds->mig_timer); reds_mig_cleanup_wait_disconnect(); } }
CWE-119
1,896
12,318
153782643349629770097729195470902326350
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_mig_cleanup_wait_disconnect(void) { RingItem *wait_client_item; while ((wait_client_item = ring_get_tail(&reds->mig_wait_disconnect_clients))) { RedsMigWaitDisconnectClient *wait_client; wait_client = SPICE_CONTAINEROF(wait_client_item, RedsMigWaitDisconnectClient, link); ring_remove(wait_client_item); free(wait_client); } reds->mig_wait_disconnect = FALSE; }
CWE-119
1,897
12,319
253403693654985958263928610594936994015
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_mig_disconnect(void) { if (reds_main_channel_connected()) { reds_disconnect(); } else { reds_mig_cleanup(); } }
CWE-119
1,898
12,320
278240234130696037154519032390879118407
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_mig_fill_wait_disconnect(void) { RingItem *client_item; spice_assert(reds->num_clients > 0); /* tracking the clients, in order to ignore disconnection * of clients that got connected to the src after migration completion.*/ RING_FOREACH(client_item, &reds->clients) { RedClient *client = SPICE_CONTAINEROF(client_item, RedClient, link); RedsMigWaitDisconnectClient *wait_client; wait_client = spice_new0(RedsMigWaitDisconnectClient, 1); wait_client->client = client; ring_add(&reds->mig_wait_disconnect_clients, &wait_client->link); } reds->mig_wait_disconnect = TRUE; core->timer_start(reds->mig_timer, MIGRATE_TIMEOUT); }
CWE-119
1,899
12,321
115710845163992249279869837191737306793
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_mig_finished(int completed) { spice_info(NULL); reds->mig_inprogress = TRUE; if (reds->src_do_seamless_migrate && completed) { reds_migrate_channels_seamless(); } else { main_channel_migrate_src_complete(reds->main_channel, completed); } if (completed) { reds_mig_fill_wait_disconnect(); } else { reds_mig_cleanup(); } reds_mig_release(); }
CWE-119
1,900
12,322
314739547030819030726807703297384395539
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_mig_release(void) { if (reds->mig_spice) { free(reds->mig_spice->cert_subject); free(reds->mig_spice->host); free(reds->mig_spice); reds->mig_spice = NULL; } }
CWE-119
1,901
12,323
226695303062112417576006110419203253104
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_mig_remove_wait_disconnect_client(RedClient *client) { RingItem *wait_client_item; RING_FOREACH(wait_client_item, &reds->mig_wait_disconnect_clients) { RedsMigWaitDisconnectClient *wait_client; wait_client = SPICE_CONTAINEROF(wait_client_item, RedsMigWaitDisconnectClient, link); if (wait_client->client == client) { ring_remove(wait_client_item); free(wait_client); if (ring_is_empty(&reds->mig_wait_disconnect_clients)) { reds_mig_cleanup(); } return; } } spice_warning("client not found %p", client); }
CWE-119
1,902
12,324
179623076062898050953870154195712583120
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_mig_started(void) { spice_info(NULL); spice_assert(reds->mig_spice); reds->mig_inprogress = TRUE; reds->mig_wait_connect = TRUE; core->timer_start(reds->mig_timer, MIGRATE_TIMEOUT); }
CWE-119
1,903
12,325
419818586049784054337466881823377341
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_mig_switch(void) { if (!reds->mig_spice) { spice_warning("reds_mig_switch called without migrate_info set"); return; } main_channel_migrate_switch(reds->main_channel, reds->mig_spice); reds_mig_release(); }
CWE-119
1,904
12,326
195602732555559687474572370096975999553
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_mig_target_client_add_pending_link(RedsMigTargetClient *client, SpiceLinkMess *link_msg, RedsStream *stream) { RedsMigPendingLink *mig_link; spice_assert(reds); spice_assert(client); mig_link = spice_malloc0(sizeof(RedsMigPendingLink)); mig_link->link_msg = link_msg; mig_link->stream = stream; ring_add(&client->pending_links, &mig_link->ring_link); }
CWE-119
1,906
12,327
121476104397289204171157367834428353355
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_mig_target_client_disconnect_all(void) { RingItem *now, *next; RING_FOREACH_SAFE(now, next, &reds->mig_target_clients) { RedsMigTargetClient *mig_client = SPICE_CONTAINEROF(now, RedsMigTargetClient, link); reds_client_disconnect(mig_client->client); } }
CWE-119
1,907
12,328
76581908409932273217148309655702558917
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static RedsMigTargetClient* reds_mig_target_client_find(RedClient *client) { RingItem *item; RING_FOREACH(item, &reds->mig_target_clients) { RedsMigTargetClient *mig_client; mig_client = SPICE_CONTAINEROF(item, RedsMigTargetClient, link); if (mig_client->client == client) { return mig_client; } } return NULL; }
CWE-119
1,908
12,329
196542163654756834651811641110736676850
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_mig_target_client_free(RedsMigTargetClient *mig_client) { RingItem *now, *next; ring_remove(&mig_client->link); reds->num_mig_target_clients--; RING_FOREACH_SAFE(now, next, &mig_client->pending_links) { RedsMigPendingLink *mig_link = SPICE_CONTAINEROF(now, RedsMigPendingLink, ring_link); ring_remove(now); free(mig_link); } free(mig_client); }
CWE-119
1,909
12,330
221517275174262596587766561088463171342
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_migrate_channels_seamless(void) { RedClient *client; /* seamless migration is supported for only one client for now */ client = reds_get_client(); red_client_migrate(client); }
CWE-119
1,910
12,331
260512255240408118013636813184263824684
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
int reds_num_of_channels(void) { return reds ? reds->num_of_channels : 0; }
CWE-119
1,911
12,332
307168335850184032425012641450522474264
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
void reds_on_char_device_state_destroy(SpiceCharDeviceState *dev) { reds_char_device_remove_state(dev); }
CWE-119
1,912
12,333
334226312422901400023792928357236160480
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
void reds_on_main_agent_data(MainChannelClient *mcc, void *message, size_t size) { VDIPortState *dev_state = &reds->agent_state; VDIChunkHeader *header; int res; res = agent_msg_filter_process_data(&reds->agent_state.write_filter, message, size); switch (res) { case AGENT_MSG_FILTER_OK: break; case AGENT_MSG_FILTER_DISCARD: return; case AGENT_MSG_FILTER_MONITORS_CONFIG: reds_on_main_agent_monitors_config(mcc, message, size); return; case AGENT_MSG_FILTER_PROTO_ERROR: red_channel_client_shutdown(main_channel_client_get_base(mcc)); return; } spice_assert(reds->agent_state.recv_from_client_buf); spice_assert(message == reds->agent_state.recv_from_client_buf->buf + sizeof(VDIChunkHeader)); header = (VDIChunkHeader *)dev_state->recv_from_client_buf->buf; header->port = VDP_CLIENT_PORT; header->size = size; dev_state->recv_from_client_buf->buf_used = sizeof(VDIChunkHeader) + size; dev_state->recv_from_client_buf_pushed = TRUE; spice_char_device_write_buffer_add(reds->agent_state.base, dev_state->recv_from_client_buf); }
CWE-119
1,915
12,334
132643246060312657275598062511249874662
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_on_main_agent_monitors_config( MainChannelClient *mcc, void *message, size_t size) { VDAgentMessage *msg_header; VDAgentMonitorsConfig *monitors_config; RedsClientMonitorsConfig *cmc = &reds->client_monitors_config; cmc->buffer_size += size; cmc->buffer = realloc(cmc->buffer, cmc->buffer_size); spice_assert(cmc->buffer); cmc->mcc = mcc; memcpy(cmc->buffer + cmc->buffer_pos, message, size); cmc->buffer_pos += size; msg_header = (VDAgentMessage *)cmc->buffer; if (sizeof(VDAgentMessage) > cmc->buffer_size || msg_header->size > cmc->buffer_size - sizeof(VDAgentMessage)) { spice_debug("not enough data yet. %d\n", cmc->buffer_size); return; } monitors_config = (VDAgentMonitorsConfig *)(cmc->buffer + sizeof(*msg_header)); spice_debug("%s: %d\n", __func__, monitors_config->num_of_monitors); red_dispatcher_client_monitors_config(monitors_config); reds_client_monitors_config_cleanup(); }
CWE-119
1,916
12,335
230207907506310941631807017053065079286
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
void reds_on_main_agent_start(MainChannelClient *mcc, uint32_t num_tokens) { SpiceCharDeviceState *dev_state = reds->agent_state.base; RedChannelClient *rcc; if (!vdagent) { return; } spice_assert(vdagent->st && vdagent->st == dev_state); rcc = main_channel_client_get_base(mcc); reds->agent_state.client_agent_started = TRUE; /* * Note that in older releases, send_tokens were set to ~0 on both client * and server. The server ignored the client given tokens. * Thanks to that, when an old client is connected to a new server, * and vice versa, the sending from the server to the client won't have * flow control, but will have no other problem. */ if (!spice_char_device_client_exists(dev_state, rcc->client)) { int client_added; client_added = spice_char_device_client_add(dev_state, rcc->client, TRUE, /* flow control */ REDS_VDI_PORT_NUM_RECEIVE_BUFFS, REDS_AGENT_WINDOW_SIZE, num_tokens, red_channel_client_waits_for_migrate_data(rcc)); if (!client_added) { spice_warning("failed to add client to agent"); red_channel_client_shutdown(rcc); return; } } else { spice_char_device_send_to_client_tokens_set(dev_state, rcc->client, num_tokens); } reds->agent_state.write_filter.discard_all = FALSE; }
CWE-119
1,917
12,336
225286668636883120503635394820288486378
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
void reds_on_main_agent_tokens(MainChannelClient *mcc, uint32_t num_tokens) { if (!vdagent) { return; } spice_assert(vdagent->st); spice_char_device_send_to_client_tokens_add(vdagent->st, main_channel_client_get_base(mcc)->client, num_tokens); }
CWE-119
1,918
12,337
290793708498662344533202239062671654801
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
void reds_on_main_channel_migrate(MainChannelClient *mcc) { VDIPortState *agent_state = &reds->agent_state; uint32_t read_data_len; spice_assert(reds->num_clients == 1); if (agent_state->read_state != VDI_PORT_READ_STATE_READ_DATA) { return; } spice_assert(agent_state->current_read_buf->data && agent_state->receive_pos > agent_state->current_read_buf->data); read_data_len = agent_state->receive_pos - agent_state->current_read_buf->data; if (agent_state->read_filter.msg_data_to_read || read_data_len > sizeof(VDAgentMessage)) { /* msg header has been read */ VDIReadBuf *read_buf = agent_state->current_read_buf; spice_debug("push partial read %u (msg first chunk? %d)", read_data_len, !agent_state->read_filter.msg_data_to_read); read_buf->len = read_data_len; if (vdi_port_read_buf_process(agent_state->vdi_chunk_header.port, read_buf)) { main_channel_client_push_agent_data(mcc, read_buf->data, read_buf->len, vdi_port_read_buf_release, read_buf); } else { vdi_port_read_buf_unref(read_buf); } spice_assert(agent_state->receive_len); agent_state->message_receive_len += agent_state->receive_len; agent_state->read_state = VDI_PORT_READ_STATE_GET_BUFF; agent_state->current_read_buf = NULL; agent_state->receive_pos = NULL; } }
CWE-119
1,919
12,338
141171712407530674323489524024851554203
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
void reds_on_main_migrate_connected(int seamless) { reds->src_do_seamless_migrate = seamless; if (reds->mig_wait_connect) { reds_mig_cleanup(); } }
CWE-119
1,920
12,339
41310022399933648631467220005860341650
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
void reds_on_main_mouse_mode_request(void *message, size_t size) { switch (((SpiceMsgcMainMouseModeRequest *)message)->mode) { case SPICE_MOUSE_MODE_CLIENT: if (reds->is_client_mouse_allowed) { reds_set_mouse_mode(SPICE_MOUSE_MODE_CLIENT); } else { spice_info("client mouse is disabled"); } break; case SPICE_MOUSE_MODE_SERVER: reds_set_mouse_mode(SPICE_MOUSE_MODE_SERVER); break; default: spice_warning("unsupported mouse mode"); } }
CWE-119
1,921
12,340
320898982856757844191186153282109040404
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
int reds_on_migrate_dst_set_seamless(MainChannelClient *mcc, uint32_t src_version) { /* seamless migration is not supported with multiple clients*/ if (reds->allow_multiple_clients || src_version > SPICE_MIGRATION_PROTOCOL_VERSION) { reds->dst_do_seamless_migrate = FALSE; } else { RedChannelClient *rcc = main_channel_client_get_base(mcc); red_client_set_migration_seamless(rcc->client); /* linking all the channels that have been connected before migration handshake */ reds->dst_do_seamless_migrate = reds_link_mig_target_channels(rcc->client); } return reds->dst_do_seamless_migrate; }
CWE-119
1,922
12,341
268069831142608902812464864878057647323
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
void reds_register_channel(RedChannel *channel) { spice_assert(reds); ring_add(&reds->channels, &channel->link); reds->num_of_channels++; }
CWE-119
1,923
12,342
156759772595633114681305548165109493860
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
void reds_release_agent_data_buffer(uint8_t *buf) { VDIPortState *dev_state = &reds->agent_state; if (!dev_state->recv_from_client_buf) { free(buf); return; } spice_assert(buf == dev_state->recv_from_client_buf->buf + sizeof(VDIChunkHeader)); if (!dev_state->recv_from_client_buf_pushed) { spice_char_device_write_buffer_release(reds->agent_state.base, dev_state->recv_from_client_buf); } dev_state->recv_from_client_buf = NULL; dev_state->recv_from_client_buf_pushed = FALSE; }
CWE-119
1,924
12,343
338270155623274555096836222030528781587
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_reset_vdp(void) { VDIPortState *state = &reds->agent_state; SpiceCharDeviceInterface *sif; state->read_state = VDI_PORT_READ_STATE_READ_HEADER; state->receive_pos = (uint8_t *)&state->vdi_chunk_header; state->receive_len = sizeof(state->vdi_chunk_header); state->message_receive_len = 0; if (state->current_read_buf) { vdi_port_read_buf_unref(state->current_read_buf); state->current_read_buf = NULL; } /* Reset read filter to start with clean state when the agent reconnects */ agent_msg_filter_init(&state->read_filter, agent_copypaste, agent_file_xfer, TRUE); /* Throw away pending chunks from the current (if any) and future * messages written by the client. * TODO: client should clear its agent messages queue when the agent * is disconnect. Currently, when and agent gets disconnected and reconnected, * messeges that were directed to the previous instance of the agent continues * to be sent from the client. This TODO will require server, protocol, and client changes */ state->write_filter.result = AGENT_MSG_FILTER_DISCARD; state->write_filter.discard_all = TRUE; state->client_agent_started = FALSE; /* reseting and not destroying the state as a workaround for a bad * tokens management in the vdagent protocol: * The client tokens' are set only once, when the main channel is initialized. * Instead, it would have been more appropriate to reset them upon AGEN_CONNECT. * The client tokens are tracked as part of the SpiceCharDeviceClientState. Thus, * in order to be backward compatible with the client, we need to track the tokens * even if the agent is detached. We don't destroy the char_device state, and * instead we just reset it. * In addition, there used to be a misshandling of AGENT_TOKENS message in spice-gtk: it * overrides the amount of tokens, instead of adding the given amount. */ if (red_channel_test_remote_cap(&reds->main_channel->base, SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS)) { spice_char_device_state_destroy(state->base); state->base = NULL; } else { spice_char_device_reset(state->base); } sif = SPICE_CONTAINEROF(vdagent->base.sif, SpiceCharDeviceInterface, base); if (sif->state) { sif->state(vdagent, 0); } }
CWE-119
1,925
12,344
326472338430636046684169214322179555169
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static int reds_send_link_ack(RedLinkInfo *link) { SpiceLinkHeader header; SpiceLinkReply ack; RedChannel *channel; RedChannelCapabilities *channel_caps; BUF_MEM *bmBuf; BIO *bio; int ret = FALSE; header.magic = SPICE_MAGIC; header.size = sizeof(ack); header.major_version = SPICE_VERSION_MAJOR; header.minor_version = SPICE_VERSION_MINOR; ack.error = SPICE_LINK_ERR_OK; channel = reds_find_channel(link->link_mess->channel_type, 0); if (!channel) { spice_assert(link->link_mess->channel_type == SPICE_CHANNEL_MAIN); spice_assert(reds->main_channel); channel = &reds->main_channel->base; } reds_channel_init_auth_caps(link, channel); /* make sure common caps are set */ channel_caps = &channel->local_caps; ack.num_common_caps = channel_caps->num_common_caps; ack.num_channel_caps = channel_caps->num_caps; header.size += (ack.num_common_caps + ack.num_channel_caps) * sizeof(uint32_t); ack.caps_offset = sizeof(SpiceLinkReply); if (!(link->tiTicketing.rsa = RSA_new())) { spice_warning("RSA nes failed"); return FALSE; } if (!(bio = BIO_new(BIO_s_mem()))) { spice_warning("BIO new failed"); return FALSE; } RSA_generate_key_ex(link->tiTicketing.rsa, SPICE_TICKET_KEY_PAIR_LENGTH, link->tiTicketing.bn, NULL); link->tiTicketing.rsa_size = RSA_size(link->tiTicketing.rsa); i2d_RSA_PUBKEY_bio(bio, link->tiTicketing.rsa); BIO_get_mem_ptr(bio, &bmBuf); memcpy(ack.pub_key, bmBuf->data, sizeof(ack.pub_key)); if (!sync_write(link->stream, &header, sizeof(header))) goto end; if (!sync_write(link->stream, &ack, sizeof(ack))) goto end; if (!sync_write(link->stream, channel_caps->common_caps, channel_caps->num_common_caps * sizeof(uint32_t))) goto end; if (!sync_write(link->stream, channel_caps->caps, channel_caps->num_caps * sizeof(uint32_t))) goto end; ret = TRUE; end: BIO_free(bio); return ret; }
CWE-119
1,927
12,345
9336435603395350858714377620317741644
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static int reds_send_link_error(RedLinkInfo *link, uint32_t error) { SpiceLinkHeader header; SpiceLinkReply reply; header.magic = SPICE_MAGIC; header.size = sizeof(reply); header.major_version = SPICE_VERSION_MAJOR; header.minor_version = SPICE_VERSION_MINOR; memset(&reply, 0, sizeof(reply)); reply.error = error; return sync_write(link->stream, &header, sizeof(header)) && sync_write(link->stream, &reply, sizeof(reply)); }
CWE-119
1,928
12,346
260665153638861236567380840582722066895
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_send_link_result(RedLinkInfo *link, uint32_t error) { sync_write(link->stream, &error, sizeof(error)); }
CWE-119
1,929
12,347
18939895681443421633463555550533798606
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_send_mm_time(void) { if (!reds_main_channel_connected()) { return; } spice_debug(NULL); main_channel_push_multi_media_time(reds->main_channel, reds_get_mm_time() - reds->mm_time_latency); }
CWE-119
1,930
12,348
135470914480566765010141950866729697487
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
void reds_set_client_mm_time_latency(RedClient *client, uint32_t latency) { if (reds->mm_timer_enabled) { if (latency > reds->mm_time_latency) { reds->mm_time_latency = latency; reds_send_mm_time(); } else { spice_debug("new latency %u is smaller than existing %u", latency, reds->mm_time_latency); } } else { snd_set_playback_latency(client, latency); } }
CWE-119
1,931
12,349
316376568721092255278093270932719074384
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
void reds_set_client_mouse_allowed(int is_client_mouse_allowed, int x_res, int y_res) { reds->monitor_mode.x_res = x_res; reds->monitor_mode.y_res = y_res; reds->dispatcher_allows_client_mouse = is_client_mouse_allowed; reds_update_mouse_mode(); if (reds->is_client_mouse_allowed && inputs_has_tablet()) { inputs_set_tablet_logical_size(reds->monitor_mode.x_res, reds->monitor_mode.y_res); } }
CWE-119
1,932
12,350
143623565698009748280648285069348491935
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static int reds_set_migration_dest_info(const char* dest, int port, int secure_port, const char* cert_subject) { RedsMigSpice *spice_migration = NULL; reds_mig_release(); if ((port == -1 && secure_port == -1) || !dest) { return FALSE; } spice_migration = spice_new0(RedsMigSpice, 1); spice_migration->port = port; spice_migration->sport = secure_port; spice_migration->host = spice_strdup(dest); if (cert_subject) { spice_migration->cert_subject = spice_strdup(cert_subject); } reds->mig_spice = spice_migration; return TRUE; }
CWE-119
1,933
12,351
256702386025596858583200871614839652861
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_set_mouse_mode(uint32_t mode) { if (reds->mouse_mode == mode) { return; } reds->mouse_mode = mode; red_dispatcher_set_mouse_mode(reds->mouse_mode); main_channel_push_mouse_mode(reds->main_channel, reds->mouse_mode, reds->is_client_mouse_allowed); }
CWE-119
1,934
12,352
183832397145933404820231179127356075591
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_start_auth_sasl(RedLinkInfo *link) { const char *mechlist = NULL; sasl_security_properties_t secprops; int err; char *localAddr, *remoteAddr; int mechlistlen; AsyncRead *obj = &link->async_read; RedsSASL *sasl = &link->stream->sasl; /* Get local & remote client addresses in form IPADDR;PORT */ if (!(localAddr = addr_to_string("%s;%s", &link->stream->info->laddr_ext, link->stream->info->llen_ext))) { goto error; } if (!(remoteAddr = addr_to_string("%s;%s", &link->stream->info->paddr_ext, link->stream->info->plen_ext))) { free(localAddr); goto error; } err = sasl_server_new("spice", NULL, /* FQDN - just delegates to gethostname */ NULL, /* User realm */ localAddr, remoteAddr, NULL, /* Callbacks, not needed */ SASL_SUCCESS_DATA, &sasl->conn); free(localAddr); free(remoteAddr); localAddr = remoteAddr = NULL; if (err != SASL_OK) { spice_warning("sasl context setup failed %d (%s)", err, sasl_errstring(err, NULL, NULL)); sasl->conn = NULL; goto error; } /* Inform SASL that we've got an external SSF layer from TLS */ if (link->stream->ssl) { sasl_ssf_t ssf; ssf = SSL_get_cipher_bits(link->stream->ssl, NULL); err = sasl_setprop(sasl->conn, SASL_SSF_EXTERNAL, &ssf); if (err != SASL_OK) { spice_warning("cannot set SASL external SSF %d (%s)", err, sasl_errstring(err, NULL, NULL)); goto error_dispose; } } else { sasl->wantSSF = 1; } memset(&secprops, 0, sizeof secprops); /* Inform SASL that we've got an external SSF layer from TLS */ if (link->stream->ssl) { /* If we've got TLS (or UNIX domain sock), we don't care about SSF */ secprops.min_ssf = 0; secprops.max_ssf = 0; secprops.maxbufsize = 8192; secprops.security_flags = 0; } else { /* Plain TCP, better get an SSF layer */ secprops.min_ssf = 56; /* Good enough to require kerberos */ secprops.max_ssf = 100000; /* Arbitrary big number */ secprops.maxbufsize = 8192; /* Forbid any anonymous or trivially crackable auth */ secprops.security_flags = SASL_SEC_NOANONYMOUS | SASL_SEC_NOPLAINTEXT; } err = sasl_setprop(sasl->conn, SASL_SEC_PROPS, &secprops); if (err != SASL_OK) { spice_warning("cannot set SASL security props %d (%s)", err, sasl_errstring(err, NULL, NULL)); goto error_dispose; } err = sasl_listmech(sasl->conn, NULL, /* Don't need to set user */ "", /* Prefix */ ",", /* Separator */ "", /* Suffix */ &mechlist, NULL, NULL); if (err != SASL_OK || mechlist == NULL) { spice_warning("cannot list SASL mechanisms %d (%s)", err, sasl_errdetail(sasl->conn)); goto error_dispose; } spice_info("Available mechanisms for client: '%s'", mechlist); sasl->mechlist = spice_strdup(mechlist); mechlistlen = strlen(mechlist); if (!sync_write(link->stream, &mechlistlen, sizeof(uint32_t)) || !sync_write(link->stream, sasl->mechlist, mechlistlen)) { spice_warning("SASL mechanisms write error"); goto error; } spice_info("Wait for client mechname length"); obj->now = (uint8_t *)&sasl->len; obj->end = obj->now + sizeof(uint32_t); obj->done = reds_handle_auth_mechlen; async_read_handler(0, 0, &link->async_read); return; error_dispose: sasl_dispose(&sasl->conn); sasl->conn = NULL; error: reds_link_free(link); return; }
CWE-119
1,935
12,353
128891806341556042377693503685461807582
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_stream_push_channel_event(RedsStream *s, int event) { main_dispatcher_channel_event(event, s->info); }
CWE-119
1,937
12,354
307267290373384352381905101428348727375
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
ssize_t reds_stream_read(RedsStream *s, void *buf, size_t nbyte) { ssize_t ret; #if HAVE_SASL if (s->sasl.conn && s->sasl.runSSF) { ret = reds_stream_sasl_read(s, buf, nbyte); } else #endif ret = s->read(s, buf, nbyte); return ret; }
CWE-119
1,938
12,355
276220860867197093053201286673160734921
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_stream_remove_watch(RedsStream* s) { if (s->watch) { core->watch_remove(s->watch); s->watch = NULL; } }
CWE-119
1,939
12,356
282606353661897496875766516753978313783
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
ssize_t reds_stream_write(RedsStream *s, const void *buf, size_t nbyte) { ssize_t ret; #if HAVE_SASL if (s->sasl.conn && s->sasl.runSSF) { ret = reds_stream_sasl_write(s, buf, nbyte); } else #endif ret = s->write(s, buf, nbyte); return ret; }
CWE-119
1,941
12,357
279686072305287719041987207561941329665
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
ssize_t reds_stream_writev(RedsStream *s, const struct iovec *iov, int iovcnt) { int i; int n; ssize_t ret = 0; if (s->writev != NULL) { return s->writev(s, iov, iovcnt); } for (i = 0; i < iovcnt; ++i) { n = reds_stream_write(s, iov[i].iov_base, iov[i].iov_len); if (n <= 0) return ret == 0 ? n : ret; ret += n; } return ret; }
CWE-119
1,942
12,358
64118521042019140192024618467582047169
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void reds_update_mouse_mode(void) { int allowed = 0; int qxl_count = red_dispatcher_qxl_count(); if ((agent_mouse && vdagent) || (inputs_has_tablet() && qxl_count == 1)) { allowed = reds->dispatcher_allows_client_mouse; } if (allowed == reds->is_client_mouse_allowed) { return; } reds->is_client_mouse_allowed = allowed; if (reds->mouse_mode == SPICE_MOUSE_MODE_CLIENT && !allowed) { reds_set_mouse_mode(SPICE_MOUSE_MODE_SERVER); return; } if (reds->main_channel) { main_channel_push_mouse_mode(reds->main_channel, reds->mouse_mode, reds->is_client_mouse_allowed); } }
CWE-119
1,944
12,359
85353159508226797170210832873028458160
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void set_image_compression(spice_image_compression_t val) { if (val == image_compression) { return; } image_compression = val; red_dispatcher_on_ic_change(); }
CWE-119
1,946
12,360
197286967308798228710959514334741060328
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
static void set_one_channel_security(int id, uint32_t security) { ChannelSecurityOptions *security_options; if ((security_options = find_channel_security(id))) { security_options->options = security; return; } security_options = spice_new(ChannelSecurityOptions, 1); security_options->channel_id = id; security_options->options = security; security_options->next = channels_security; channels_security = security_options; }
CWE-119
1,947
12,361
128191811357859179484571638260073408659
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE spice_compat_version_t spice_get_current_compat_version(void) { return SPICE_COMPAT_VERSION_CURRENT; }
CWE-119
1,948
12,362
99340686765721113668417790975044434422
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_add_client(SpiceServer *s, int socket, int skip_auth) { RedLinkInfo *link; RedsStream *stream; spice_assert(reds == s); if (!(link = reds_init_client_connection(socket))) { spice_warning("accept failed"); return -1; } link->skip_auth = skip_auth; stream = link->stream; stream->read = stream_read_cb; stream->write = stream_write_cb; stream->writev = stream_writev_cb; reds_handle_new_link(link); return 0; }
CWE-119
1,949
12,363
86767652069580946604025064662825697858
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *s, SpiceBaseInstance *sin) { const SpiceBaseInterface *interface = sin->sif; spice_assert(reds == s); if (strcmp(interface->type, SPICE_INTERFACE_KEYBOARD) == 0) { spice_info("SPICE_INTERFACE_KEYBOARD"); if (interface->major_version != SPICE_INTERFACE_KEYBOARD_MAJOR || interface->minor_version > SPICE_INTERFACE_KEYBOARD_MINOR) { spice_warning("unsupported keyboard interface"); return -1; } if (inputs_set_keyboard(SPICE_CONTAINEROF(sin, SpiceKbdInstance, base)) != 0) { return -1; } } else if (strcmp(interface->type, SPICE_INTERFACE_MOUSE) == 0) { spice_info("SPICE_INTERFACE_MOUSE"); if (interface->major_version != SPICE_INTERFACE_MOUSE_MAJOR || interface->minor_version > SPICE_INTERFACE_MOUSE_MINOR) { spice_warning("unsupported mouse interface"); return -1; } if (inputs_set_mouse(SPICE_CONTAINEROF(sin, SpiceMouseInstance, base)) != 0) { return -1; } } else if (strcmp(interface->type, SPICE_INTERFACE_QXL) == 0) { QXLInstance *qxl; spice_info("SPICE_INTERFACE_QXL"); if (interface->major_version != SPICE_INTERFACE_QXL_MAJOR || interface->minor_version > SPICE_INTERFACE_QXL_MINOR) { spice_warning("unsupported qxl interface"); return -1; } qxl = SPICE_CONTAINEROF(sin, QXLInstance, base); qxl->st = spice_new0(QXLState, 1); qxl->st->qif = SPICE_CONTAINEROF(interface, QXLInterface, base); red_dispatcher_init(qxl); } else if (strcmp(interface->type, SPICE_INTERFACE_TABLET) == 0) { spice_info("SPICE_INTERFACE_TABLET"); if (interface->major_version != SPICE_INTERFACE_TABLET_MAJOR || interface->minor_version > SPICE_INTERFACE_TABLET_MINOR) { spice_warning("unsupported tablet interface"); return -1; } if (inputs_set_tablet(SPICE_CONTAINEROF(sin, SpiceTabletInstance, base)) != 0) { return -1; } reds_update_mouse_mode(); if (reds->is_client_mouse_allowed) { inputs_set_tablet_logical_size(reds->monitor_mode.x_res, reds->monitor_mode.y_res); } } else if (strcmp(interface->type, SPICE_INTERFACE_PLAYBACK) == 0) { spice_info("SPICE_INTERFACE_PLAYBACK"); if (interface->major_version != SPICE_INTERFACE_PLAYBACK_MAJOR || interface->minor_version > SPICE_INTERFACE_PLAYBACK_MINOR) { spice_warning("unsupported playback interface"); return -1; } snd_attach_playback(SPICE_CONTAINEROF(sin, SpicePlaybackInstance, base)); } else if (strcmp(interface->type, SPICE_INTERFACE_RECORD) == 0) { spice_info("SPICE_INTERFACE_RECORD"); if (interface->major_version != SPICE_INTERFACE_RECORD_MAJOR || interface->minor_version > SPICE_INTERFACE_RECORD_MINOR) { spice_warning("unsupported record interface"); return -1; } snd_attach_record(SPICE_CONTAINEROF(sin, SpiceRecordInstance, base)); } else if (strcmp(interface->type, SPICE_INTERFACE_CHAR_DEVICE) == 0) { if (interface->major_version != SPICE_INTERFACE_CHAR_DEVICE_MAJOR || interface->minor_version > SPICE_INTERFACE_CHAR_DEVICE_MINOR) { spice_warning("unsupported char device interface"); return -1; } spice_server_char_device_add_interface(s, sin); } else if (strcmp(interface->type, SPICE_INTERFACE_NET_WIRE) == 0) { spice_warning("unsupported net wire interface"); return -1; } else if (strcmp(interface->type, SPICE_INTERFACE_MIGRATION) == 0) { spice_info("SPICE_INTERFACE_MIGRATION"); if (migration_interface) { spice_warning("already have migration"); return -1; } if (interface->major_version != SPICE_INTERFACE_MIGRATION_MAJOR || interface->minor_version > SPICE_INTERFACE_MIGRATION_MINOR) { spice_warning("unsupported migration interface"); return -1; } migration_interface = SPICE_CONTAINEROF(sin, SpiceMigrateInstance, base); migration_interface->st = spice_new0(SpiceMigrateState, 1); } return 0; }
CWE-119
1,950
12,364
88893090644406327743534922036028066810
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_add_ssl_client(SpiceServer *s, int socket, int skip_auth) { RedLinkInfo *link; spice_assert(reds == s); if (!(link = reds_init_client_ssl_connection(socket))) { return -1; } link->skip_auth = skip_auth; return 0; }
CWE-119
1,952
12,365
151610867433680420305617705975032349334
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE const char** spice_server_char_device_recognized_subtypes(void) { return spice_server_char_device_recognized_subtypes_list; }
CWE-119
1,954
12,366
303129388083346249773215625390420895117
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE void spice_server_char_device_wakeup(SpiceCharDeviceInstance* sin) { if (!sin->st) { spice_warning("no SpiceCharDeviceState attached to instance %p", sin); return; } spice_char_device_wakeup(sin->st); }
CWE-119
1,956
12,367
92673826773654589908905255369698254056
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE void spice_server_destroy(SpiceServer *s) { spice_assert(reds == s); reds_exit(); }
CWE-119
1,957
12,368
9105601002741171578565954929012924268
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE spice_image_compression_t spice_server_get_image_compression(SpiceServer *s) { spice_assert(reds == s); return image_compression; }
CWE-119
1,958
12,369
262261663725867081803326258959425047974
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_get_num_clients(SpiceServer *s) { spice_assert(reds == s); return reds_num_of_clients(); }
CWE-119
1,959
12,370
27489738003638952466423666215639105224
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_get_peer_info(SpiceServer *s, struct sockaddr *sa, socklen_t *salen) { spice_assert(reds == s); if (main_channel_getpeername(reds->main_channel, sa, salen) < 0) { return -1; } return 0; }
CWE-119
1,960
12,371
303217298083803558839092873505083212333
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_get_sock_info(SpiceServer *s, struct sockaddr *sa, socklen_t *salen) { spice_assert(reds == s); if (main_channel_getsockname(reds->main_channel, sa, salen) < 0) { return -1; } return 0; }
CWE-119
1,961
12,372
305015728196298376431112879983674857591
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_init(SpiceServer *s, SpiceCoreInterface *core) { int ret; spice_assert(reds == s); ret = do_spice_init(core); if (default_renderer) { red_dispatcher_add_renderer(default_renderer); } return ret; }
CWE-119
1,962
12,373
269206431763986793341783710884632595193
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_is_server_mouse(SpiceServer *s) { spice_assert(reds == s); return reds->mouse_mode == SPICE_MOUSE_MODE_SERVER; }
CWE-119
1,963
12,374
133895451763324954734005114632238916560
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_kbd_leds(SpiceKbdInstance *sin, int leds) { inputs_on_keyboard_leds_change(NULL, leds); return 0; }
CWE-119
1,964
12,375
276015613851021576194068564033914046908
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_migrate_client_state(SpiceServer *s) { spice_assert(reds == s); if (!reds_main_channel_connected()) { return SPICE_MIGRATE_CLIENT_NONE; } else if (reds->mig_wait_connect) { return SPICE_MIGRATE_CLIENT_WAITING; } else { return SPICE_MIGRATE_CLIENT_READY; } return 0; }
CWE-119
1,965
12,376
101865536084751938664300554496773602517
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_migrate_connect(SpiceServer *s, const char* dest, int port, int secure_port, const char* cert_subject) { SpiceMigrateInterface *sif; int try_seamless; spice_info(NULL); spice_assert(migration_interface); spice_assert(reds == s); if (reds->expect_migrate) { spice_info("consecutive calls without migration. Canceling previous call"); main_channel_migrate_src_complete(reds->main_channel, FALSE); } sif = SPICE_CONTAINEROF(migration_interface->base.sif, SpiceMigrateInterface, base); if (!reds_set_migration_dest_info(dest, port, secure_port, cert_subject)) { sif->migrate_connect_complete(migration_interface); return -1; } reds->expect_migrate = TRUE; /* * seamless migration support was added to the client after the support in * agent_connect_tokens, so there shouldn't be contradicition - if * the client is capable of seamless migration, it is capbable of agent_connected_tokens. * The demand for agent_connected_tokens support is in order to assure that if migration * occured when the agent was not connected, the tokens state after migration will still * be valid (see reds_reset_vdp for more details). */ try_seamless = reds->seamless_migration_enabled && red_channel_test_remote_cap(&reds->main_channel->base, SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS); /* main channel will take care of clients that are still during migration (at target)*/ if (main_channel_migrate_connect(reds->main_channel, reds->mig_spice, try_seamless)) { reds_mig_started(); } else { if (reds->num_clients == 0) { reds_mig_release(); spice_info("no client connected"); } sif->migrate_connect_complete(migration_interface); } return 0; }
CWE-119
1,966
12,377
159350543767006229903320297753698796900
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_migrate_end(SpiceServer *s, int completed) { SpiceMigrateInterface *sif; int ret = 0; spice_info(NULL); spice_assert(migration_interface); spice_assert(reds == s); sif = SPICE_CONTAINEROF(migration_interface->base.sif, SpiceMigrateInterface, base); if (completed && !reds->expect_migrate && reds->num_clients) { spice_warning("spice_server_migrate_info was not called, disconnecting clients"); reds_disconnect(); ret = -1; goto complete; } reds->expect_migrate = FALSE; if (!reds_main_channel_connected()) { spice_info("no peer connected"); goto complete; } reds_mig_finished(completed); return 0; complete: if (sif->migrate_end_complete) { sif->migrate_end_complete(migration_interface); } return ret; }
CWE-119
1,967
12,378
308277652063169924080603499741624750238
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_migrate_info(SpiceServer *s, const char* dest, int port, int secure_port, const char* cert_subject) { spice_info(NULL); spice_assert(!migration_interface); spice_assert(reds == s); if (!reds_set_migration_dest_info(dest, port, secure_port, cert_subject)) { return -1; } return 0; }
CWE-119
1,968
12,379
176437197570506391488811588127170712106
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_migrate_switch(SpiceServer *s) { spice_assert(reds == s); spice_info(NULL); if (!reds->num_clients) { return 0; } reds->expect_migrate = FALSE; reds_mig_switch(); return 0; }
CWE-119
1,969
12,380
253432749641257799394738180181303616725
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE SpiceServer *spice_server_new(void) { /* we can't handle multiple instances (yet) */ spice_assert(reds == NULL); reds = spice_new0(RedsState, 1); return reds; }
CWE-119
1,970
12,381
262107588481650163059447526766564494772
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE void spice_server_set_addr(SpiceServer *s, const char *addr, int flags) { spice_assert(reds == s); g_strlcpy(spice_addr, addr, sizeof(spice_addr)); if (flags & SPICE_ADDR_FLAG_IPV4_ONLY) { spice_family = PF_INET; } if (flags & SPICE_ADDR_FLAG_IPV6_ONLY) { spice_family = PF_INET6; } }
CWE-119
1,972
12,382
218821190751226607479668219629262889364
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_set_agent_copypaste(SpiceServer *s, int enable) { spice_assert(reds == s); agent_copypaste = enable; reds->agent_state.write_filter.copy_paste_enabled = agent_copypaste; reds->agent_state.read_filter.copy_paste_enabled = agent_copypaste; return 0; }
CWE-119
1,973
12,383
72028985320289838722286612566626694279
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_set_agent_file_xfer(SpiceServer *s, int enable) { spice_assert(reds == s); agent_file_xfer = enable; reds->agent_state.write_filter.file_xfer_enabled = agent_file_xfer; reds->agent_state.read_filter.file_xfer_enabled = agent_file_xfer; return 0; }
CWE-119
1,974
12,384
67823361048639207038539880572494679593
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_set_channel_security(SpiceServer *s, const char *channel, int security) { static const char *names[] = { [ SPICE_CHANNEL_MAIN ] = "main", [ SPICE_CHANNEL_DISPLAY ] = "display", [ SPICE_CHANNEL_INPUTS ] = "inputs", [ SPICE_CHANNEL_CURSOR ] = "cursor", [ SPICE_CHANNEL_PLAYBACK ] = "playback", [ SPICE_CHANNEL_RECORD ] = "record", #ifdef USE_SMARTCARD [ SPICE_CHANNEL_SMARTCARD] = "smartcard", #endif [ SPICE_CHANNEL_USBREDIR ] = "usbredir", }; int i; spice_assert(reds == s); if (channel == NULL) { default_channel_security = security; return 0; } for (i = 0; i < SPICE_N_ELEMENTS(names); i++) { if (names[i] && strcmp(names[i], channel) == 0) { set_one_channel_security(i, security); return 0; } } return -1; }
CWE-119
1,976
12,385
82816467290886678643611803368551600936
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_set_compat_version(SpiceServer *s, spice_compat_version_t version) { if (version < SPICE_COMPAT_VERSION_0_6) { /* We don't support 0.4 compat mode atm */ return -1; } if (version > SPICE_COMPAT_VERSION_CURRENT) { /* Not compatible with future versions */ return -1; } return 0; }
CWE-119
1,977
12,386
92322522005752286289377012309385639848
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_set_exit_on_disconnect(SpiceServer *s, int flag) { spice_assert(reds == s); exit_on_disconnect = !!flag; return 0; }
CWE-119
1,978
12,387
68197038726701781020533533378435569988
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_set_image_compression(SpiceServer *s, spice_image_compression_t comp) { spice_assert(reds == s); set_image_compression(comp); return 0; }
CWE-119
1,979
12,388
288550308163387730935341400304965260969
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_set_jpeg_compression(SpiceServer *s, spice_wan_compression_t comp) { spice_assert(reds == s); if (comp == SPICE_WAN_COMPRESSION_INVALID) { spice_error("invalid jpeg state"); return -1; } jpeg_state = comp; return 0; }
CWE-119
1,980
12,389
285359456275091303529803837376188094599
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_set_listen_socket_fd(SpiceServer *s, int listen_fd) { spice_assert(reds == s); spice_listen_socket_fd = listen_fd; return 0; }
CWE-119
1,981
12,390
12644046157221250047250606980771742681
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE void spice_server_set_name(SpiceServer *s, const char *name) { free(spice_name); spice_name = spice_strdup(name); }
CWE-119
1,982
12,391
206031007371551759856904353899715395283
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_set_noauth(SpiceServer *s) { spice_assert(reds == s); memset(taTicket.password, 0, sizeof(taTicket.password)); ticketing_enabled = 0; return 0; }
CWE-119
1,983
12,392
102331403260721270624678765443755805060
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_set_playback_compression(SpiceServer *s, int enable) { spice_assert(reds == s); snd_set_playback_compression(enable); return 0; }
CWE-119
1,984
12,393
200615964159715373747154790282386075825
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_set_port(SpiceServer *s, int port) { spice_assert(reds == s); if (port < 0 || port > 0xffff) { return -1; } spice_port = port; return 0; }
CWE-119
1,985
12,394
182951123139633896108546026572239170
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_set_sasl(SpiceServer *s, int enabled) { spice_assert(reds == s); #if HAVE_SASL sasl_enabled = enabled; return 0; #else return -1; #endif }
CWE-119
1,986
12,395
258713538713094382403222030799022129580
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_set_sasl_appname(SpiceServer *s, const char *appname) { spice_assert(reds == s); #if HAVE_SASL free(sasl_appname); sasl_appname = spice_strdup(appname); return 0; #else return -1; #endif }
CWE-119
1,987
12,396
332087916377493997803786888338995375442
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE void spice_server_set_seamless_migration(SpiceServer *s, int enable) { spice_assert(s == reds); /* seamless migration is not supported with multiple clients */ reds->seamless_migration_enabled = enable && !reds->allow_multiple_clients; spice_debug("seamless migration enabled=%d", enable); }
CWE-119
1,988
12,397
10571528736434147180251668275452982044
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_set_streaming_video(SpiceServer *s, int value) { spice_assert(reds == s); if (value != SPICE_STREAM_VIDEO_OFF && value != SPICE_STREAM_VIDEO_ALL && value != SPICE_STREAM_VIDEO_FILTER) return -1; streaming_video = value; red_dispatcher_on_sv_change(); return 0; }
CWE-119
1,989
12,398
83849097836437639469229282571581176290
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_set_ticket(SpiceServer *s, const char *passwd, int lifetime, int fail_if_connected, int disconnect_if_connected) { spice_assert(reds == s); if (reds_main_channel_connected()) { if (fail_if_connected) { return -1; } if (disconnect_if_connected) { reds_disconnect(); } } on_activating_ticketing(); ticketing_enabled = 1; if (lifetime == 0) { taTicket.expiration_time = INT_MAX; } else { time_t now = time(NULL); taTicket.expiration_time = now + lifetime; } if (passwd != NULL) { g_strlcpy(taTicket.password, passwd, sizeof(taTicket.password)); } else { memset(taTicket.password, 0, sizeof(taTicket.password)); taTicket.expiration_time = 0; } return 0; }
CWE-119
1,990
12,399
91509267939669892911722408326355844913
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_set_tls(SpiceServer *s, int port, const char *ca_cert_file, const char *certs_file, const char *private_key_file, const char *key_passwd, const char *dh_key_file, const char *ciphersuite) { spice_assert(reds == s); if (port == 0 || ca_cert_file == NULL || certs_file == NULL || private_key_file == NULL) { return -1; } if (port < 0 || port > 0xffff) { return -1; } memset(&ssl_parameters, 0, sizeof(ssl_parameters)); spice_secure_port = port; g_strlcpy(ssl_parameters.ca_certificate_file, ca_cert_file, sizeof(ssl_parameters.ca_certificate_file)); g_strlcpy(ssl_parameters.certs_file, certs_file, sizeof(ssl_parameters.certs_file)); g_strlcpy(ssl_parameters.private_key_file, private_key_file, sizeof(ssl_parameters.private_key_file)); if (key_passwd) { g_strlcpy(ssl_parameters.keyfile_password, key_passwd, sizeof(ssl_parameters.keyfile_password)); } if (ciphersuite) { g_strlcpy(ssl_parameters.ciphersuite, ciphersuite, sizeof(ssl_parameters.ciphersuite)); } if (dh_key_file) { g_strlcpy(ssl_parameters.dh_key_file, dh_key_file, sizeof(ssl_parameters.dh_key_file)); } return 0; }
CWE-119
1,991
12,400
152983711243881622369388502485257051231
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE void spice_server_set_uuid(SpiceServer *s, const uint8_t uuid[16]) { memcpy(spice_uuid, uuid, sizeof(spice_uuid)); spice_uuid_is_set = TRUE; }
CWE-119
1,992
12,401
235026872069199041387712528234885179172
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE int spice_server_set_zlib_glz_compression(SpiceServer *s, spice_wan_compression_t comp) { spice_assert(reds == s); if (comp == SPICE_WAN_COMPRESSION_INVALID) { spice_error("invalid zlib_glz state"); return -1; } zlib_glz_state = comp; return 0; }
CWE-119
1,993
12,402
299659171049327002802888032725364292786
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE void spice_server_vm_start(SpiceServer *s) { RingItem *item; spice_assert(s == reds); reds->vm_running = TRUE; RING_FOREACH(item, &reds->char_devs_states) { SpiceCharDeviceStateItem *st_item; st_item = SPICE_CONTAINEROF(item, SpiceCharDeviceStateItem, link); spice_char_device_start(st_item->st); } red_dispatcher_on_vm_start(); }
CWE-119
1,994
12,403
297133376616898801083939964820715387525
null
null
null
spice
8af619009660b24e0b41ad26b30289eea288fcc2
0
SPICE_GNUC_VISIBLE void spice_server_vm_stop(SpiceServer *s) { RingItem *item; spice_assert(s == reds); reds->vm_running = FALSE; RING_FOREACH(item, &reds->char_devs_states) { SpiceCharDeviceStateItem *st_item; st_item = SPICE_CONTAINEROF(item, SpiceCharDeviceStateItem, link); spice_char_device_stop(st_item->st); } red_dispatcher_on_vm_stop(); }
CWE-119
1,995
12,404
303333808868231151791344232312785009261
null
null
null