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
53488f0275d6c8a121af49f7ac817d09ce68090d
0
static void red_channel_client_send_set_ack(RedChannelClient *rcc) { SpiceMsgSetAck ack; spice_assert(rcc); red_channel_client_init_send_data(rcc, SPICE_MSG_SET_ACK, NULL); ack.generation = ++rcc->ack_data.generation; ack.window = rcc->ack_data.client_window; rcc->ack_data.messages_window = 0; spice_marshall_msg_set_ack(rcc->send_data.marshaller, &ack); red_channel_client_begin_send_message(rcc); }
CWE-399
2,140
12,527
220028754355311322758528628744779967820
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
void red_channel_client_set_message_serial(RedChannelClient *rcc, uint64_t serial) { rcc->send_data.last_sent_serial = serial; rcc->send_data.serial = serial; }
CWE-399
2,142
12,528
333652373756030749056123348436398890548
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
static void red_channel_client_set_migration_seamless(RedChannelClient *rcc) { spice_assert(rcc->client->during_target_migrate && rcc->client->seamless_migrate); if (rcc->channel->migration_flags & SPICE_MIGRATE_NEED_DATA_TRANSFER) { rcc->wait_migrate_data = TRUE; rcc->client->num_migrated_channels++; } spice_debug("channel type %d id %d rcc %p wait data %d", rcc->channel->type, rcc->channel->id, rcc, rcc->wait_migrate_data); }
CWE-399
2,143
12,529
18874892864046733654866263569874951462
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
static void red_channel_client_set_remote_caps(RedChannelClient* rcc, int num_common_caps, uint32_t *common_caps, int num_caps, uint32_t *caps) { rcc->remote_caps.num_common_caps = num_common_caps; rcc->remote_caps.common_caps = spice_memdup(common_caps, num_common_caps * sizeof(uint32_t)); rcc->remote_caps.num_caps = num_caps; rcc->remote_caps.caps = spice_memdup(caps, num_caps * sizeof(uint32_t)); }
CWE-399
2,144
12,530
175926471653704789667195843053770999007
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
static void red_channel_client_start_ping_timer(RedChannelClient *rcc, uint32_t timeout) { if (!rcc->latency_monitor.timer) { return; } if (rcc->latency_monitor.state != PING_STATE_NONE) { return; } rcc->latency_monitor.state = PING_STATE_TIMER; rcc->channel->core->timer_start(rcc->latency_monitor.timer, timeout); }
CWE-399
2,146
12,531
35716001855740137713510908798347973234
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
int red_channel_client_test_remote_cap(RedChannelClient *rcc, uint32_t cap) { return test_capabilty(rcc->remote_caps.caps, rcc->remote_caps.num_caps, cap); }
CWE-399
2,147
12,532
267655586889197914787034665153811062271
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
int red_channel_client_test_remote_common_cap(RedChannelClient *rcc, uint32_t cap) { return test_capabilty(rcc->remote_caps.common_caps, rcc->remote_caps.num_common_caps, cap); }
CWE-399
2,148
12,533
313043257500073120848430052167387368112
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
static void red_channel_client_unref(RedChannelClient *rcc) { if (!--rcc->refs) { if (rcc->send_data.main.marshaller) { spice_marshaller_destroy(rcc->send_data.main.marshaller); } if (rcc->send_data.urgent.marshaller) { spice_marshaller_destroy(rcc->send_data.urgent.marshaller); } red_channel_client_destroy_remote_caps(rcc); if (rcc->channel) { red_channel_unref(rcc->channel); } free(rcc); } }
CWE-399
2,149
12,534
46340103187900789894265289050453143572
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
static inline int red_channel_client_urgent_marshaller_is_active(RedChannelClient *rcc) { return (rcc->send_data.marshaller == rcc->send_data.urgent.marshaller); }
CWE-399
2,150
12,535
105910283935387418724621477061973605069
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
static inline int red_channel_client_waiting_for_ack(RedChannelClient *rcc) { return (rcc->channel->handle_acks && (rcc->ack_data.messages_window > rcc->ack_data.client_window * 2)); }
CWE-399
2,151
12,536
238956215530179383704796677653904783398
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
int red_channel_client_waits_for_migrate_data(RedChannelClient *rcc) { return rcc->wait_migrate_data; }
CWE-399
2,152
12,537
97859630013639685118969620421573562422
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
RedChannel *red_channel_create(int size, SpiceCoreInterface *core, uint32_t type, uint32_t id, int handle_acks, channel_handle_message_proc handle_message, ChannelCbs *channel_cbs, uint32_t migration_flags) { RedChannel *channel; ClientCbs client_cbs = { NULL, }; spice_assert(size >= sizeof(*channel)); spice_assert(channel_cbs->config_socket && channel_cbs->on_disconnect && handle_message && channel_cbs->alloc_recv_buf && channel_cbs->release_item); spice_assert(channel_cbs->handle_migrate_data || !(migration_flags & SPICE_MIGRATE_NEED_DATA_TRANSFER)); channel = spice_malloc0(size); channel->type = type; channel->id = id; channel->refs = 1; channel->handle_acks = handle_acks; channel->migration_flags = migration_flags; memcpy(&channel->channel_cbs, channel_cbs, sizeof(ChannelCbs)); channel->core = core; ring_init(&channel->clients); channel->incoming_cb.alloc_msg_buf = (alloc_msg_recv_buf_proc)channel_cbs->alloc_recv_buf; channel->incoming_cb.release_msg_buf = (release_msg_recv_buf_proc)channel_cbs->release_recv_buf; channel->incoming_cb.handle_message = (handle_message_proc)handle_message; channel->incoming_cb.on_error = (on_incoming_error_proc)red_channel_client_default_peer_on_error; channel->outgoing_cb.get_msg_size = red_channel_client_peer_get_out_msg_size; channel->outgoing_cb.prepare = red_channel_client_peer_prepare_out_msg; channel->outgoing_cb.on_block = red_channel_client_peer_on_out_block; channel->outgoing_cb.on_error = (on_outgoing_error_proc)red_channel_client_default_peer_on_error; channel->outgoing_cb.on_msg_done = red_channel_peer_on_out_msg_done; channel->outgoing_cb.on_output = red_channel_client_on_output; client_cbs.connect = red_channel_client_default_connect; client_cbs.disconnect = red_channel_client_default_disconnect; client_cbs.migrate = red_channel_client_default_migrate; red_channel_register_client_cbs(channel, &client_cbs); red_channel_set_common_cap(channel, SPICE_COMMON_CAP_MINI_HEADER); channel->thread_id = pthread_self(); channel->out_bytes_counter = 0; spice_debug("channel type %d id %d thread_id 0x%lx", channel->type, channel->id, channel->thread_id); return channel; }
CWE-399
2,153
12,538
54835027982849994107501625363411006180
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
RedChannel *red_channel_create_dummy(int size, uint32_t type, uint32_t id) { RedChannel *channel; ClientCbs client_cbs = { NULL, }; spice_assert(size >= sizeof(*channel)); channel = spice_malloc0(size); channel->type = type; channel->id = id; channel->refs = 1; channel->core = &dummy_core; ring_init(&channel->clients); client_cbs.connect = red_channel_client_default_connect; client_cbs.disconnect = red_channel_client_default_disconnect; client_cbs.migrate = red_channel_client_default_migrate; red_channel_register_client_cbs(channel, &client_cbs); red_channel_set_common_cap(channel, SPICE_COMMON_CAP_MINI_HEADER); channel->thread_id = pthread_self(); spice_debug("channel type %d id %d thread_id 0x%lx", channel->type, channel->id, channel->thread_id); channel->out_bytes_counter = 0; return channel; }
CWE-399
2,154
12,539
252900038205076615459630415695226273404
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
RedChannel *red_channel_create_parser(int size, SpiceCoreInterface *core, uint32_t type, uint32_t id, int handle_acks, spice_parse_channel_func_t parser, channel_handle_parsed_proc handle_parsed, ChannelCbs *channel_cbs, uint32_t migration_flags) { RedChannel *channel = red_channel_create(size, core, type, id, handle_acks, do_nothing_handle_message, channel_cbs, migration_flags); if (channel == NULL) { return NULL; } channel->incoming_cb.handle_parsed = (handle_parsed_proc)handle_parsed; channel->incoming_cb.parser = parser; return channel; }
CWE-399
2,155
12,540
293908157397617851329176351459604476339
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
void red_channel_destroy(RedChannel *channel) { RingItem *link; RingItem *next; if (!channel) { return; } RING_FOREACH_SAFE(link, next, &channel->clients) { red_channel_client_destroy( SPICE_CONTAINEROF(link, RedChannelClient, channel_link)); } red_channel_unref(channel); }
CWE-399
2,156
12,541
297622806879232456747476512254117102301
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
static void red_channel_handle_migrate_data(RedChannelClient *rcc, uint32_t size, void *message) { spice_debug("channel type %d id %d rcc %p size %u", rcc->channel->type, rcc->channel->id, rcc, size); if (!rcc->channel->channel_cbs.handle_migrate_data) { return; } if (!red_channel_client_waits_for_migrate_data(rcc)) { spice_channel_client_error(rcc, "unexpected"); return; } if (rcc->channel->channel_cbs.handle_migrate_data_get_serial) { red_channel_client_set_message_serial(rcc, rcc->channel->channel_cbs.handle_migrate_data_get_serial(rcc, size, message)); } if (!rcc->channel->channel_cbs.handle_migrate_data(rcc, size, message)) { spice_channel_client_error(rcc, "handle_migrate_data failed"); return; } red_channel_client_seamless_migration_done(rcc); }
CWE-399
2,158
12,542
5767856774549702980453464690307639142
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
static void red_channel_handle_migrate_flush_mark(RedChannelClient *rcc) { if (rcc->channel->channel_cbs.handle_migrate_flush_mark) { rcc->channel->channel_cbs.handle_migrate_flush_mark(rcc); } }
CWE-399
2,159
12,543
210253878530436934464495947214045898143
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
void red_channel_init_outgoing_messages_window(RedChannel *channel) { RingItem *link; RingItem *next; RING_FOREACH_SAFE(link, next, &channel->clients) { red_channel_client_init_outgoing_messages_window( SPICE_CONTAINEROF(link, RedChannelClient, channel_link)); } }
CWE-399
2,160
12,544
334975406098808940626159570170206615866
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
uint32_t red_channel_min_pipe_size(RedChannel *channel) { RingItem *link; RedChannelClient *rcc; uint32_t pipe_size = ~0; RING_FOREACH(link, &channel->clients) { rcc = SPICE_CONTAINEROF(link, RedChannelClient, channel_link); pipe_size = pipe_size < rcc->pipe_size ? pipe_size : rcc->pipe_size; } return pipe_size == ~0 ? 0 : pipe_size; }
CWE-399
2,163
12,545
176442985003791943818574943131176930758
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
int red_channel_no_item_being_sent(RedChannel *channel) { RingItem *link; RedChannelClient *rcc; RING_FOREACH(link, &channel->clients) { rcc = SPICE_CONTAINEROF(link, RedChannelClient, channel_link); if (!red_channel_client_no_item_being_sent(rcc)) { return FALSE; } } return TRUE; }
CWE-399
2,164
12,546
11965183038308165594627656686364126951
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
void red_channel_pipe_item_init(RedChannel *channel, PipeItem *item, int type) { ring_item_init(&item->link); item->type = type; }
CWE-399
2,166
12,547
331959602365877317892056851941516621948
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
void red_channel_pipes_new_add(RedChannel *channel, new_pipe_item_t creator, void *data) { red_channel_pipes_create_batch(channel, creator, data, red_channel_client_pipe_add); }
CWE-399
2,168
12,548
103025597834196461223104520193291358354
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
void red_channel_pipes_new_add_push(RedChannel *channel, new_pipe_item_t creator, void *data) { red_channel_pipes_create_batch(channel, creator, data, red_channel_client_pipe_add); red_channel_push(channel); }
CWE-399
2,169
12,549
239479517237043572247578697061634905692
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
void red_channel_push(RedChannel *channel) { RingItem *link; RingItem *next; RedChannelClient *rcc; if (!channel) { return; } RING_FOREACH_SAFE(link, next, &channel->clients) { rcc = SPICE_CONTAINEROF(link, RedChannelClient, channel_link); red_channel_client_push(rcc); } }
CWE-399
2,171
12,550
114439448224540284680382481122083415633
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
void red_channel_receive(RedChannel *channel) { RingItem *link; RingItem *next; RedChannelClient *rcc; RING_FOREACH_SAFE(link, next, &channel->clients) { rcc = SPICE_CONTAINEROF(link, RedChannelClient, channel_link); red_channel_client_receive(rcc); } }
CWE-399
2,173
12,551
204689296702642633492347167085097890784
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
static void red_channel_ref(RedChannel *channel) { channel->refs++; }
CWE-399
2,174
12,552
220779958993770814193680244703109759886
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
void red_channel_register_client_cbs(RedChannel *channel, ClientCbs *client_cbs) { spice_assert(client_cbs->connect || channel->type == SPICE_CHANNEL_MAIN); channel->client_cbs.connect = client_cbs->connect; if (client_cbs->disconnect) { channel->client_cbs.disconnect = client_cbs->disconnect; } if (client_cbs->migrate) { channel->client_cbs.migrate = client_cbs->migrate; } }
CWE-399
2,175
12,553
229213062250391432014582344538189059009
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
static void red_channel_remove_client(RedChannelClient *rcc) { if (!pthread_equal(pthread_self(), rcc->channel->thread_id)) { spice_warning("channel type %d id %d - " "channel->thread_id (0x%lx) != pthread_self (0x%lx)." "If one of the threads is != io-thread && != vcpu-thread, " "this might be a BUG", rcc->channel->type, rcc->channel->id, rcc->channel->thread_id, pthread_self()); } ring_remove(&rcc->channel_link); spice_assert(rcc->channel->clients_num > 0); rcc->channel->clients_num--; }
CWE-399
2,176
12,554
92429403216911537883909922854000703034
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
void red_channel_send(RedChannel *channel) { RingItem *link; RingItem *next; RING_FOREACH_SAFE(link, next, &channel->clients) { red_channel_client_send(SPICE_CONTAINEROF(link, RedChannelClient, channel_link)); } }
CWE-399
2,177
12,555
177662869470296120263579174114973240260
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
void red_channel_set_cap(RedChannel *channel, uint32_t cap) { add_capability(&channel->local_caps.caps, &channel->local_caps.num_caps, cap); }
CWE-399
2,178
12,556
89179074656586501912475093991483565012
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
void red_channel_set_data(RedChannel *channel, void *data) { spice_assert(channel); channel->data = data; }
CWE-399
2,180
12,557
126913446103668745806247178782017121270
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
uint32_t red_channel_sum_pipes_size(RedChannel *channel) { RingItem *link; RedChannelClient *rcc; uint32_t sum = 0; RING_FOREACH(link, &channel->clients) { rcc = SPICE_CONTAINEROF(link, RedChannelClient, channel_link); sum += rcc->pipe_size; } return sum; }
CWE-399
2,181
12,558
229707971744110065052829857898195151065
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
int red_channel_test_remote_cap(RedChannel *channel, uint32_t cap) { RingItem *link; RING_FOREACH(link, &channel->clients) { RedChannelClient *rcc = SPICE_CONTAINEROF(link, RedChannelClient, channel_link); if (!red_channel_client_test_remote_cap(rcc, cap)) { return FALSE; } } return TRUE; }
CWE-399
2,182
12,559
72425594046635721510677151345987357363
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
int red_channel_test_remote_common_cap(RedChannel *channel, uint32_t cap) { RingItem *link; RING_FOREACH(link, &channel->clients) { RedChannelClient *rcc = SPICE_CONTAINEROF(link, RedChannelClient, channel_link); if (!red_channel_client_test_remote_common_cap(rcc, cap)) { return FALSE; } } return TRUE; }
CWE-399
2,183
12,560
311572290763414421788266488615289450946
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
static void red_channel_unref(RedChannel *channel) { if (!--channel->refs) { if (channel->local_caps.num_common_caps) { free(channel->local_caps.common_caps); } if (channel->local_caps.num_caps) { free(channel->local_caps.caps); } free(channel); } }
CWE-399
2,184
12,561
146452876954865923294353801290606912186
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
int red_channel_waits_for_migrate_data(RedChannel *channel) { RedChannelClient *rcc; if (!red_channel_is_connected(channel)) { return FALSE; } if (channel->clients_num > 1) { return FALSE; } spice_assert(channel->clients_num == 1); rcc = SPICE_CONTAINEROF(ring_get_head(&channel->clients), RedChannelClient, channel_link); return red_channel_client_waits_for_migrate_data(rcc); }
CWE-399
2,185
12,562
187002055935134948161652741982292434953
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
static void red_client_add_channel(RedClient *client, RedChannelClient *rcc) { spice_assert(rcc && client); ring_add(&client->channels, &rcc->client_link); if (client->during_target_migrate && client->seamless_migrate) { red_channel_client_set_migration_seamless(rcc); } client->channels_num++; }
CWE-399
2,186
12,563
103304816233578019609254055800900175569
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
void red_client_destroy(RedClient *client) { RingItem *link, *next; RedChannelClient *rcc; spice_printerr("destroy client with #channels %d", client->channels_num); if (!pthread_equal(pthread_self(), client->thread_id)) { spice_warning("client->thread_id (0x%lx) != pthread_self (0x%lx)." "If one of the threads is != io-thread && != vcpu-thread," " this might be a BUG", client->thread_id, pthread_self()); } RING_FOREACH_SAFE(link, next, &client->channels) { rcc = SPICE_CONTAINEROF(link, RedChannelClient, client_link); rcc->destroying = 1; rcc->channel->client_cbs.disconnect(rcc); spice_assert(ring_is_empty(&rcc->pipe)); spice_assert(rcc->pipe_size == 0); spice_assert(rcc->send_data.size == 0); red_channel_client_destroy(rcc); } pthread_mutex_destroy(&client->lock); free(client); }
CWE-399
2,187
12,564
39713263073954394582450019385005666062
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
int red_client_during_migrate_at_target(RedClient *client) { int ret; pthread_mutex_lock(&client->lock); ret = client->during_target_migrate; pthread_mutex_unlock(&client->lock); return ret; }
CWE-399
2,188
12,565
110639191543275080559897218527656091875
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
static RedChannelClient *red_client_get_channel(RedClient *client, int type, int id) { RingItem *link; RedChannelClient *rcc; RedChannelClient *ret = NULL; RING_FOREACH(link, &client->channels) { rcc = SPICE_CONTAINEROF(link, RedChannelClient, client_link); if (rcc->channel->type == type && rcc->channel->id == id) { ret = rcc; break; } } return ret; }
CWE-399
2,189
12,566
245337931316319588958770814983974466368
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
MainChannelClient *red_client_get_main(RedClient *client) { return client->mcc; }
CWE-399
2,190
12,567
199524170780823830997198300041994597429
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
void red_client_migrate(RedClient *client) { RingItem *link, *next; RedChannelClient *rcc; spice_printerr("migrate client with #channels %d", client->channels_num); if (!pthread_equal(pthread_self(), client->thread_id)) { spice_warning("client->thread_id (0x%lx) != pthread_self (0x%lx)." "If one of the threads is != io-thread && != vcpu-thread," " this might be a BUG", client->thread_id, pthread_self()); } RING_FOREACH_SAFE(link, next, &client->channels) { rcc = SPICE_CONTAINEROF(link, RedChannelClient, client_link); if (red_channel_client_is_connected(rcc)) { rcc->channel->client_cbs.migrate(rcc); } } }
CWE-399
2,191
12,568
137972210053449633528371592318059496252
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
RedClient *red_client_new(int migrated) { RedClient *client; client = spice_malloc0(sizeof(RedClient)); ring_init(&client->channels); pthread_mutex_init(&client->lock, NULL); client->thread_id = pthread_self(); client->during_target_migrate = migrated; return client; }
CWE-399
2,192
12,569
300969726879090854800116302845209389368
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
static void red_client_remove_channel(RedChannelClient *rcc) { pthread_mutex_lock(&rcc->client->lock); ring_remove(&rcc->client_link); rcc->client->channels_num--; pthread_mutex_unlock(&rcc->client->lock); }
CWE-399
2,193
12,570
120816244854140042972442634412678673804
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
void red_client_semi_seamless_migrate_complete(RedClient *client) { RingItem *link; pthread_mutex_lock(&client->lock); if (!client->during_target_migrate || client->seamless_migrate) { spice_error("unexpected"); pthread_mutex_unlock(&client->lock); return; } client->during_target_migrate = FALSE; RING_FOREACH(link, &client->channels) { RedChannelClient *rcc = SPICE_CONTAINEROF(link, RedChannelClient, client_link); if (rcc->latency_monitor.timer) { red_channel_client_start_ping_timer(rcc, PING_TEST_IDLE_NET_TIMEOUT_MS); } } pthread_mutex_unlock(&client->lock); reds_on_client_semi_seamless_migrate_complete(client); }
CWE-399
2,194
12,571
35108736732040496451522964413673976702
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
void red_client_set_migration_seamless(RedClient *client) // dest { RingItem *link; pthread_mutex_lock(&client->lock); client->seamless_migrate = TRUE; /* update channel clients that got connected before the migration * type was set. red_client_add_channel will handle newer channel clients */ RING_FOREACH(link, &client->channels) { RedChannelClient *rcc = SPICE_CONTAINEROF(link, RedChannelClient, client_link); red_channel_client_set_migration_seamless(rcc); } pthread_mutex_unlock(&client->lock); }
CWE-399
2,196
12,572
22273518261898526432576646128306846948
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
static void red_peer_handle_outgoing(RedsStream *stream, OutgoingHandler *handler) { ssize_t n; if (!stream) { return; } if (handler->size == 0) { handler->vec = handler->vec_buf; handler->size = handler->cb->get_msg_size(handler->opaque); if (!handler->size) { // nothing to be sent return; } } for (;;) { handler->cb->prepare(handler->opaque, handler->vec, &handler->vec_size, handler->pos); n = reds_stream_writev(stream, handler->vec, handler->vec_size); if (n == -1) { switch (errno) { case EAGAIN: handler->cb->on_block(handler->opaque); return; case EINTR: continue; case EPIPE: handler->cb->on_error(handler->opaque); return; default: spice_printerr("%s", strerror(errno)); handler->cb->on_error(handler->opaque); return; } } else { handler->pos += n; handler->cb->on_output(handler->opaque, n); if (handler->pos == handler->size) { // finished writing data /* reset handler before calling on_msg_done, since it * can trigger another call to red_peer_handle_outgoing (when * switching from the urgent marshaller to the main one */ handler->vec = handler->vec_buf; handler->pos = 0; handler->size = 0; handler->cb->on_msg_done(handler->opaque); return; } } } }
CWE-399
2,198
12,573
266010055500513787480495134919619120792
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
static int red_peer_receive(RedsStream *stream, uint8_t *buf, uint32_t size) { uint8_t *pos = buf; while (size) { int now; if (stream->shutdown) { return -1; } now = reds_stream_read(stream, pos, size); if (now <= 0) { if (now == 0) { return -1; } spice_assert(now == -1); if (errno == EAGAIN) { break; } else if (errno == EINTR) { continue; } else if (errno == EPIPE) { return -1; } else { spice_printerr("%s", strerror(errno)); return -1; } } else { size -= now; pos += now; } } return pos - buf; }
CWE-399
2,199
12,574
223655969181937914612629165133677905273
null
null
null
spice
53488f0275d6c8a121af49f7ac817d09ce68090d
0
int test_capabilty(uint32_t *caps, int num_caps, uint32_t cap) { uint32_t index = cap / 32; if (num_caps < index + 1) { return FALSE; } return (caps[index] & (1 << (cap % 32))) != 0; }
CWE-399
2,200
12,575
55459836844780845187211002091004881413
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
FoFiType1C::FoFiType1C(char *fileA, int lenA, GBool freeFileDataA): FoFiBase(fileA, lenA, freeFileDataA) { name = NULL; encoding = NULL; privateDicts = NULL; fdSelect = NULL; charset = NULL; charsetLength = 0; }
CWE-125
2,201
12,576
132930680239200203040175267188542067113
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
void FoFiType1C::buildEncoding() { char buf[256]; int nCodes, nRanges, encFormat; int pos, c, sid, nLeft, nSups, i, j; if (topDict.encodingOffset == 0) { encoding = (char **)fofiType1StandardEncoding; } else if (topDict.encodingOffset == 1) { encoding = (char **)fofiType1ExpertEncoding; } else { encoding = (char **)gmallocn(256, sizeof(char *)); for (i = 0; i < 256; ++i) { encoding[i] = NULL; } pos = topDict.encodingOffset; encFormat = getU8(pos++, &parsedOk); if (!parsedOk) { return; } if ((encFormat & 0x7f) == 0) { nCodes = 1 + getU8(pos++, &parsedOk); if (!parsedOk) { return; } if (nCodes > nGlyphs) { nCodes = nGlyphs; } for (i = 1; i < nCodes && i < charsetLength; ++i) { c = getU8(pos++, &parsedOk); if (!parsedOk) { return; } if (encoding[c]) { gfree(encoding[c]); } encoding[c] = copyString(getString(charset[i], buf, &parsedOk)); } } else if ((encFormat & 0x7f) == 1) { nRanges = getU8(pos++, &parsedOk); if (!parsedOk) { return; } nCodes = 1; for (i = 0; i < nRanges; ++i) { c = getU8(pos++, &parsedOk); nLeft = getU8(pos++, &parsedOk); if (!parsedOk) { return; } for (j = 0; j <= nLeft && nCodes < nGlyphs && nCodes < charsetLength; ++j) { if (c < 256) { if (encoding[c]) { gfree(encoding[c]); } encoding[c] = copyString(getString(charset[nCodes], buf, &parsedOk)); } ++nCodes; ++c; } } } if (encFormat & 0x80) { nSups = getU8(pos++, &parsedOk); if (!parsedOk) { return; } for (i = 0; i < nSups; ++i) { c = getU8(pos++, &parsedOk);; if (!parsedOk) { return;; } sid = getU16BE(pos, &parsedOk); pos += 2; if (!parsedOk) { return; } if (encoding[c]) { gfree(encoding[c]); } encoding[c] = copyString(getString(sid, buf, &parsedOk)); } } } }
CWE-125
2,202
12,577
162671353550294694835426404015851180142
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
void FoFiType1C::convertToCIDType0(char *psName, int *codeMap, int nCodes, FoFiOutputFunc outputFunc, void *outputStream) { int *cidMap; GooString *charStrings; int *charStringOffsets; Type1CIndex subrIdx; Type1CIndexVal val; int nCIDs, gdBytes; GooString *buf; char buf2[256]; GBool ok; int gid, offset, n, i, j, k; if (codeMap) { nCIDs = nCodes; cidMap = (int *)gmallocn(nCIDs, sizeof(int)); for (i = 0; i < nCodes; ++i) { if (codeMap[i] >= 0 && codeMap[i] < nGlyphs) { cidMap[i] = codeMap[i]; } else { cidMap[i] = -1; } } } else if (topDict.firstOp == 0x0c1e) { nCIDs = 0; for (i = 0; i < nGlyphs && i < charsetLength; ++i) { if (charset[i] >= nCIDs) { nCIDs = charset[i] + 1; } } cidMap = (int *)gmallocn(nCIDs, sizeof(int)); for (i = 0; i < nCIDs; ++i) { cidMap[i] = -1; } for (i = 0; i < nGlyphs && i < charsetLength; ++i) { cidMap[charset[i]] = i; } } else { nCIDs = nGlyphs; cidMap = (int *)gmallocn(nCIDs, sizeof(int)); for (i = 0; i < nCIDs; ++i) { cidMap[i] = i; } } charStrings = new GooString(); charStringOffsets = (int *)gmallocn(nCIDs + 1, sizeof(int)); for (i = 0; i < nCIDs; ++i) { charStringOffsets[i] = charStrings->getLength(); if ((gid = cidMap[i]) >= 0) { ok = gTrue; getIndexVal(&charStringsIdx, gid, &val, &ok); if (ok) { getIndex(privateDicts[fdSelect ? fdSelect[gid] : 0].subrsOffset, &subrIdx, &ok); if (!ok) { subrIdx.pos = -1; } cvtGlyph(val.pos, val.len, charStrings, &subrIdx, &privateDicts[fdSelect ? fdSelect[gid] : 0], gTrue); } } } charStringOffsets[nCIDs] = charStrings->getLength(); i = (nCIDs + 1) * 5 + charStrings->getLength(); if (i < 0x100) { gdBytes = 1; } else if (i < 0x10000) { gdBytes = 2; } else if (i < 0x1000000) { gdBytes = 3; } else { gdBytes = 4; } (*outputFunc)(outputStream, "/CIDInit /ProcSet findresource begin\n", 37); (*outputFunc)(outputStream, "20 dict begin\n", 14); (*outputFunc)(outputStream, "/CIDFontName /", 14); (*outputFunc)(outputStream, psName, strlen(psName)); (*outputFunc)(outputStream, " def\n", 5); (*outputFunc)(outputStream, "/CIDFontType 0 def\n", 19); (*outputFunc)(outputStream, "/CIDSystemInfo 3 dict dup begin\n", 32); if (topDict.registrySID > 0 && topDict.orderingSID > 0) { ok = gTrue; getString(topDict.registrySID, buf2, &ok); if (ok) { (*outputFunc)(outputStream, " /Registry (", 13); (*outputFunc)(outputStream, buf2, strlen(buf2)); (*outputFunc)(outputStream, ") def\n", 6); } ok = gTrue; getString(topDict.orderingSID, buf2, &ok); if (ok) { (*outputFunc)(outputStream, " /Ordering (", 13); (*outputFunc)(outputStream, buf2, strlen(buf2)); (*outputFunc)(outputStream, ") def\n", 6); } } else { (*outputFunc)(outputStream, " /Registry (Adobe) def\n", 24); (*outputFunc)(outputStream, " /Ordering (Identity) def\n", 27); } buf = GooString::format(" /Supplement {0:d} def\n", topDict.supplement); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; (*outputFunc)(outputStream, "end def\n", 8); if (topDict.hasFontMatrix) { buf = GooString::format("/FontMatrix [{0:.8g} {1:.8g} {2:.8g} {3:.8g} {4:.8g} {5:.8g}] def\n", topDict.fontMatrix[0], topDict.fontMatrix[1], topDict.fontMatrix[2], topDict.fontMatrix[3], topDict.fontMatrix[4], topDict.fontMatrix[5]); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } else if (privateDicts[0].hasFontMatrix) { (*outputFunc)(outputStream, "/FontMatrix [1 0 0 1 0 0] def\n", 30); } else { (*outputFunc)(outputStream, "/FontMatrix [0.001 0 0 0.001 0 0] def\n", 38); } buf = GooString::format("/FontBBox [{0:.4g} {1:.4g} {2:.4g} {3:.4g}] def\n", topDict.fontBBox[0], topDict.fontBBox[1], topDict.fontBBox[2], topDict.fontBBox[3]); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; (*outputFunc)(outputStream, "/FontInfo 1 dict dup begin\n", 27); (*outputFunc)(outputStream, " /FSType 8 def\n", 16); (*outputFunc)(outputStream, "end def\n", 8); buf = GooString::format("/CIDCount {0:d} def\n", nCIDs); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; (*outputFunc)(outputStream, "/FDBytes 1 def\n", 15); buf = GooString::format("/GDBytes {0:d} def\n", gdBytes); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; (*outputFunc)(outputStream, "/CIDMapOffset 0 def\n", 20); if (topDict.paintType != 0) { buf = GooString::format("/PaintType {0:d} def\n", topDict.paintType); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; buf = GooString::format("/StrokeWidth {0:.4g} def\n", topDict.strokeWidth); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } buf = GooString::format("/FDArray {0:d} array\n", nFDs); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; for (i = 0; i < nFDs; ++i) { buf = GooString::format("dup {0:d} 10 dict begin\n", i); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; (*outputFunc)(outputStream, "/FontType 1 def\n", 16); if (privateDicts[i].hasFontMatrix) { buf = GooString::format("/FontMatrix [{0:.8g} {1:.8g} {2:.8g} {3:.8g} {4:.8g} {5:.8g}] def\n", privateDicts[i].fontMatrix[0], privateDicts[i].fontMatrix[1], privateDicts[i].fontMatrix[2], privateDicts[i].fontMatrix[3], privateDicts[i].fontMatrix[4], privateDicts[i].fontMatrix[5]); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } else { (*outputFunc)(outputStream, "/FontMatrix [1 0 0 1 0 0] def\n", 30); } buf = GooString::format("/PaintType {0:d} def\n", topDict.paintType); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; (*outputFunc)(outputStream, "/Private 32 dict begin\n", 23); if (privateDicts[i].nBlueValues) { (*outputFunc)(outputStream, "/BlueValues [", 13); for (j = 0; j < privateDicts[i].nBlueValues; ++j) { buf = GooString::format("{0:s}{1:d}", j > 0 ? " " : "", privateDicts[i].blueValues[j]); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } (*outputFunc)(outputStream, "] def\n", 6); } if (privateDicts[i].nOtherBlues) { (*outputFunc)(outputStream, "/OtherBlues [", 13); for (j = 0; j < privateDicts[i].nOtherBlues; ++j) { buf = GooString::format("{0:s}{1:d}", j > 0 ? " " : "", privateDicts[i].otherBlues[j]); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } (*outputFunc)(outputStream, "] def\n", 6); } if (privateDicts[i].nFamilyBlues) { (*outputFunc)(outputStream, "/FamilyBlues [", 14); for (j = 0; j < privateDicts[i].nFamilyBlues; ++j) { buf = GooString::format("{0:s}{1:d}", j > 0 ? " " : "", privateDicts[i].familyBlues[j]); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } (*outputFunc)(outputStream, "] def\n", 6); } if (privateDicts[i].nFamilyOtherBlues) { (*outputFunc)(outputStream, "/FamilyOtherBlues [", 19); for (j = 0; j < privateDicts[i].nFamilyOtherBlues; ++j) { buf = GooString::format("{0:s}{1:d}", j > 0 ? " " : "", privateDicts[i].familyOtherBlues[j]); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } (*outputFunc)(outputStream, "] def\n", 6); } if (privateDicts[i].blueScale != 0.039625) { buf = GooString::format("/BlueScale {0:.4g} def\n", privateDicts[i].blueScale); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } if (privateDicts[i].blueShift != 7) { buf = GooString::format("/BlueShift {0:d} def\n", privateDicts[i].blueShift); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } if (privateDicts[i].blueFuzz != 1) { buf = GooString::format("/BlueFuzz {0:d} def\n", privateDicts[i].blueFuzz); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } if (privateDicts[i].hasStdHW) { buf = GooString::format("/StdHW [{0:.4g}] def\n", privateDicts[i].stdHW); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } if (privateDicts[i].hasStdVW) { buf = GooString::format("/StdVW [{0:.4g}] def\n", privateDicts[i].stdVW); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } if (privateDicts[i].nStemSnapH) { (*outputFunc)(outputStream, "/StemSnapH [", 12); for (j = 0; j < privateDicts[i].nStemSnapH; ++j) { buf = GooString::format("{0:s}{1:.4g}", j > 0 ? " " : "", privateDicts[i].stemSnapH[j]); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } (*outputFunc)(outputStream, "] def\n", 6); } if (privateDicts[i].nStemSnapV) { (*outputFunc)(outputStream, "/StemSnapV [", 12); for (j = 0; j < privateDicts[i].nStemSnapV; ++j) { buf = GooString::format("{0:s}{1:.4g}", j > 0 ? " " : "", privateDicts[i].stemSnapV[j]); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } (*outputFunc)(outputStream, "] def\n", 6); } if (privateDicts[i].hasForceBold) { buf = GooString::format("/ForceBold {0:s} def\n", privateDicts[i].forceBold ? "true" : "false"); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } if (privateDicts[i].forceBoldThreshold != 0) { buf = GooString::format("/ForceBoldThreshold {0:.4g} def\n", privateDicts[i].forceBoldThreshold); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } if (privateDicts[i].languageGroup != 0) { buf = GooString::format("/LanguageGroup {0:d} def\n", privateDicts[i].languageGroup); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } if (privateDicts[i].expansionFactor != 0.06) { buf = GooString::format("/ExpansionFactor {0:.4g} def\n", privateDicts[i].expansionFactor); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } (*outputFunc)(outputStream, "currentdict end def\n", 20); (*outputFunc)(outputStream, "currentdict end put\n", 20); } (*outputFunc)(outputStream, "def\n", 4); offset = (nCIDs + 1) * (1 + gdBytes); buf = GooString::format("(Hex) {0:d} StartData\n", offset + charStrings->getLength()); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; for (i = 0; i <= nCIDs; i += 6) { for (j = 0; j < 6 && i+j <= nCIDs; ++j) { if (i+j < nCIDs && cidMap[i+j] >= 0 && fdSelect) { buf2[0] = (char)fdSelect[cidMap[i+j]]; } else { buf2[0] = (char)0; } n = offset + charStringOffsets[i+j]; for (k = gdBytes; k >= 1; --k) { buf2[k] = (char)(n & 0xff); n >>= 8; } for (k = 0; k <= gdBytes; ++k) { buf = GooString::format("{0:02x}", buf2[k] & 0xff); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } } (*outputFunc)(outputStream, "\n", 1); } n = charStrings->getLength(); for (i = 0; i < n; i += 32) { for (j = 0; j < 32 && i+j < n; ++j) { buf = GooString::format("{0:02x}", charStrings->getChar(i+j) & 0xff); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } if (i + 32 >= n) { (*outputFunc)(outputStream, ">", 1); } (*outputFunc)(outputStream, "\n", 1); } gfree(charStringOffsets); delete charStrings; gfree(cidMap); }
CWE-125
2,203
12,578
97095882244718154474863621702944886153
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
void FoFiType1C::convertToType1(char *psName, const char **newEncoding, GBool ascii, FoFiOutputFunc outputFunc, void *outputStream) { int psNameLen; Type1CEexecBuf eb; Type1CIndex subrIdx; Type1CIndexVal val; GooString *buf; char buf2[256]; const char **enc; GBool ok; int i; if (psName) { psNameLen = strlen(psName); } else { psName = name->getCString(); psNameLen = name->getLength(); } ok = gTrue; (*outputFunc)(outputStream, "%!FontType1-1.0: ", 17); (*outputFunc)(outputStream, psName, psNameLen); if (topDict.versionSID != 0) { getString(topDict.versionSID, buf2, &ok); (*outputFunc)(outputStream, buf2, strlen(buf2)); } (*outputFunc)(outputStream, "\n", 1); (*outputFunc)(outputStream, "12 dict begin\n", 14); (*outputFunc)(outputStream, "/FontInfo 10 dict dup begin\n", 28); if (topDict.versionSID != 0) { (*outputFunc)(outputStream, "/version ", 9); writePSString(buf2, outputFunc, outputStream); (*outputFunc)(outputStream, " readonly def\n", 14); } if (topDict.noticeSID != 0) { getString(topDict.noticeSID, buf2, &ok); (*outputFunc)(outputStream, "/Notice ", 8); writePSString(buf2, outputFunc, outputStream); (*outputFunc)(outputStream, " readonly def\n", 14); } if (topDict.copyrightSID != 0) { getString(topDict.copyrightSID, buf2, &ok); (*outputFunc)(outputStream, "/Copyright ", 11); writePSString(buf2, outputFunc, outputStream); (*outputFunc)(outputStream, " readonly def\n", 14); } if (topDict.fullNameSID != 0) { getString(topDict.fullNameSID, buf2, &ok); (*outputFunc)(outputStream, "/FullName ", 10); writePSString(buf2, outputFunc, outputStream); (*outputFunc)(outputStream, " readonly def\n", 14); } if (topDict.familyNameSID != 0) { getString(topDict.familyNameSID, buf2, &ok); (*outputFunc)(outputStream, "/FamilyName ", 12); writePSString(buf2, outputFunc, outputStream); (*outputFunc)(outputStream, " readonly def\n", 14); } if (topDict.weightSID != 0) { getString(topDict.weightSID, buf2, &ok); (*outputFunc)(outputStream, "/Weight ", 8); writePSString(buf2, outputFunc, outputStream); (*outputFunc)(outputStream, " readonly def\n", 14); } if (topDict.isFixedPitch) { (*outputFunc)(outputStream, "/isFixedPitch true def\n", 23); } else { (*outputFunc)(outputStream, "/isFixedPitch false def\n", 24); } buf = GooString::format("/ItalicAngle {0:.4g} def\n", topDict.italicAngle); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; buf = GooString::format("/UnderlinePosition {0:.4g} def\n", topDict.underlinePosition); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; buf = GooString::format("/UnderlineThickness {0:.4g} def\n", topDict.underlineThickness); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; (*outputFunc)(outputStream, "end readonly def\n", 17); (*outputFunc)(outputStream, "/FontName /", 11); (*outputFunc)(outputStream, psName, psNameLen); (*outputFunc)(outputStream, " def\n", 5); buf = GooString::format("/PaintType {0:d} def\n", topDict.paintType); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; (*outputFunc)(outputStream, "/FontType 1 def\n", 16); buf = GooString::format("/FontMatrix [{0:.8g} {1:.8g} {2:.8g} {3:.8g} {4:.8g} {5:.8g}] readonly def\n", topDict.fontMatrix[0], topDict.fontMatrix[1], topDict.fontMatrix[2], topDict.fontMatrix[3], topDict.fontMatrix[4], topDict.fontMatrix[5]); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; buf = GooString::format("/FontBBox [{0:.4g} {1:.4g} {2:.4g} {3:.4g}] readonly def\n", topDict.fontBBox[0], topDict.fontBBox[1], topDict.fontBBox[2], topDict.fontBBox[3]); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; buf = GooString::format("/StrokeWidth {0:.4g} def\n", topDict.strokeWidth); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; if (topDict.uniqueID != 0) { buf = GooString::format("/UniqueID {0:d} def\n", topDict.uniqueID); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } (*outputFunc)(outputStream, "/Encoding ", 10); if (!newEncoding && encoding == fofiType1StandardEncoding) { (*outputFunc)(outputStream, "StandardEncoding def\n", 21); } else { (*outputFunc)(outputStream, "256 array\n", 10); (*outputFunc)(outputStream, "0 1 255 {1 index exch /.notdef put} for\n", 40); enc = newEncoding ? newEncoding : (const char **)encoding; for (i = 0; i < 256; ++i) { if (enc[i]) { buf = GooString::format("dup {0:d} /{1:s} put\n", i, enc[i]); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } } (*outputFunc)(outputStream, "readonly def\n", 13); } (*outputFunc)(outputStream, "currentdict end\n", 16); (*outputFunc)(outputStream, "currentfile eexec\n", 18); eb.outputFunc = outputFunc; eb.outputStream = outputStream; eb.ascii = ascii; eb.r1 = 55665; eb.line = 0; eexecWrite(&eb, "\x83\xca\x73\xd5"); eexecWrite(&eb, "dup /Private 32 dict dup begin\n"); eexecWrite(&eb, "/RD {string currentfile exch readstring pop}" " executeonly def\n"); eexecWrite(&eb, "/ND {noaccess def} executeonly def\n"); eexecWrite(&eb, "/NP {noaccess put} executeonly def\n"); eexecWrite(&eb, "/MinFeature {16 16} def\n"); eexecWrite(&eb, "/password 5839 def\n"); if (privateDicts[0].nBlueValues) { eexecWrite(&eb, "/BlueValues ["); for (i = 0; i < privateDicts[0].nBlueValues; ++i) { buf = GooString::format("{0:s}{1:d}", i > 0 ? " " : "", privateDicts[0].blueValues[i]); eexecWrite(&eb, buf->getCString()); delete buf; } eexecWrite(&eb, "] def\n"); } if (privateDicts[0].nOtherBlues) { eexecWrite(&eb, "/OtherBlues ["); for (i = 0; i < privateDicts[0].nOtherBlues; ++i) { buf = GooString::format("{0:s}{1:d}", i > 0 ? " " : "", privateDicts[0].otherBlues[i]); eexecWrite(&eb, buf->getCString()); delete buf; } eexecWrite(&eb, "] def\n"); } if (privateDicts[0].nFamilyBlues) { eexecWrite(&eb, "/FamilyBlues ["); for (i = 0; i < privateDicts[0].nFamilyBlues; ++i) { buf = GooString::format("{0:s}{1:d}", i > 0 ? " " : "", privateDicts[0].familyBlues[i]); eexecWrite(&eb, buf->getCString()); delete buf; } eexecWrite(&eb, "] def\n"); } if (privateDicts[0].nFamilyOtherBlues) { eexecWrite(&eb, "/FamilyOtherBlues ["); for (i = 0; i < privateDicts[0].nFamilyOtherBlues; ++i) { buf = GooString::format("{0:s}{1:d}", i > 0 ? " " : "", privateDicts[0].familyOtherBlues[i]); eexecWrite(&eb, buf->getCString()); delete buf; } eexecWrite(&eb, "] def\n"); } if (privateDicts[0].blueScale != 0.039625) { buf = GooString::format("/BlueScale {0:.4g} def\n", privateDicts[0].blueScale); eexecWrite(&eb, buf->getCString()); delete buf; } if (privateDicts[0].blueShift != 7) { buf = GooString::format("/BlueShift {0:d} def\n", privateDicts[0].blueShift); eexecWrite(&eb, buf->getCString()); delete buf; } if (privateDicts[0].blueFuzz != 1) { buf = GooString::format("/BlueFuzz {0:d} def\n", privateDicts[0].blueFuzz); eexecWrite(&eb, buf->getCString()); delete buf; } if (privateDicts[0].hasStdHW) { buf = GooString::format("/StdHW [{0:.4g}] def\n", privateDicts[0].stdHW); eexecWrite(&eb, buf->getCString()); delete buf; } if (privateDicts[0].hasStdVW) { buf = GooString::format("/StdVW [{0:.4g}] def\n", privateDicts[0].stdVW); eexecWrite(&eb, buf->getCString()); delete buf; } if (privateDicts[0].nStemSnapH) { eexecWrite(&eb, "/StemSnapH ["); for (i = 0; i < privateDicts[0].nStemSnapH; ++i) { buf = GooString::format("{0:s}{1:.4g}", i > 0 ? " " : "", privateDicts[0].stemSnapH[i]); eexecWrite(&eb, buf->getCString()); delete buf; } eexecWrite(&eb, "] def\n"); } if (privateDicts[0].nStemSnapV) { eexecWrite(&eb, "/StemSnapV ["); for (i = 0; i < privateDicts[0].nStemSnapV; ++i) { buf = GooString::format("{0:s}{1:.4g}", i > 0 ? " " : "", privateDicts[0].stemSnapV[i]); eexecWrite(&eb, buf->getCString()); delete buf; } eexecWrite(&eb, "] def\n"); } if (privateDicts[0].hasForceBold) { buf = GooString::format("/ForceBold {0:s} def\n", privateDicts[0].forceBold ? "true" : "false"); eexecWrite(&eb, buf->getCString()); delete buf; } if (privateDicts[0].forceBoldThreshold != 0) { buf = GooString::format("/ForceBoldThreshold {0:.4g} def\n", privateDicts[0].forceBoldThreshold); eexecWrite(&eb, buf->getCString()); delete buf; } if (privateDicts[0].languageGroup != 0) { buf = GooString::format("/LanguageGroup {0:d} def\n", privateDicts[0].languageGroup); eexecWrite(&eb, buf->getCString()); delete buf; } if (privateDicts[0].expansionFactor != 0.06) { buf = GooString::format("/ExpansionFactor {0:.4g} def\n", privateDicts[0].expansionFactor); eexecWrite(&eb, buf->getCString()); delete buf; } ok = gTrue; getIndex(privateDicts[0].subrsOffset, &subrIdx, &ok); if (!ok) { subrIdx.pos = -1; } buf = GooString::format("2 index /CharStrings {0:d} dict dup begin\n", nGlyphs); eexecWrite(&eb, buf->getCString()); delete buf; for (i = 0; i < nGlyphs; ++i) { ok = gTrue; getIndexVal(&charStringsIdx, i, &val, &ok); if (ok && i < charsetLength) { getString(charset[i], buf2, &ok); if (ok) { eexecCvtGlyph(&eb, buf2, val.pos, val.len, &subrIdx, &privateDicts[0]); } } } eexecWrite(&eb, "end\n"); eexecWrite(&eb, "end\n"); eexecWrite(&eb, "readonly put\n"); eexecWrite(&eb, "noaccess put\n"); eexecWrite(&eb, "dup /FontName get exch definefont pop\n"); eexecWrite(&eb, "mark currentfile closefile\n"); if (ascii && eb.line > 0) { (*outputFunc)(outputStream, "\n", 1); } for (i = 0; i < 8; ++i) { (*outputFunc)(outputStream, "0000000000000000000000000000000000000000000000000000000000000000\n", 65); } (*outputFunc)(outputStream, "cleartomark\n", 12); }
CWE-125
2,204
12,579
9038964464295006561041151130318317095
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
void FoFiType1C::cvtGlyph(int offset, int nBytes, GooString *charBuf, Type1CIndex *subrIdx, Type1CPrivateDict *pDict, GBool top) { Type1CIndexVal val; GBool ok, dFP; double d, dx, dy; Gushort r2; Guchar byte; int pos, subrBias, start, i, k; start = charBuf->getLength(); if (top) { charBuf->append((char)73); charBuf->append((char)58); charBuf->append((char)147); charBuf->append((char)134); nOps = 0; nHints = 0; firstOp = gTrue; openPath = gFalse; } pos = offset; while (pos < offset + nBytes) { ok = gTrue; pos = getOp(pos, gTrue, &ok); if (!ok) { break; } if (!ops[nOps - 1].isNum) { --nOps; // drop the operator switch (ops[nOps].op) { case 0x0001: // hstem if (firstOp) { cvtGlyphWidth(nOps & 1, charBuf, pDict); firstOp = gFalse; } if (nOps & 1) { } d = 0; dFP = gFalse; for (k = 0; k < nOps; k += 2) { if (ops[k+1].num < 0) { d += ops[k].num + ops[k+1].num; dFP |= ops[k].isFP | ops[k+1].isFP; cvtNum(d, dFP, charBuf); cvtNum(-ops[k+1].num, ops[k+1].isFP, charBuf); } else { d += ops[k].num; dFP |= ops[k].isFP; cvtNum(d, dFP, charBuf); cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf); d += ops[k+1].num; dFP |= ops[k+1].isFP; } charBuf->append((char)1); } nHints += nOps / 2; nOps = 0; break; case 0x0003: // vstem if (firstOp) { cvtGlyphWidth(nOps & 1, charBuf, pDict); firstOp = gFalse; } if (nOps & 1) { } d = 0; dFP = gFalse; for (k = 0; k < nOps; k += 2) { if (ops[k+1].num < 0) { d += ops[k].num + ops[k+1].num; dFP |= ops[k].isFP | ops[k+1].isFP; cvtNum(d, dFP, charBuf); cvtNum(-ops[k+1].num, ops[k+1].isFP, charBuf); } else { d += ops[k].num; dFP |= ops[k].isFP; cvtNum(d, dFP, charBuf); cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf); d += ops[k+1].num; dFP |= ops[k+1].isFP; } charBuf->append((char)3); } nHints += nOps / 2; nOps = 0; break; case 0x0004: // vmoveto if (firstOp) { cvtGlyphWidth(nOps == 2, charBuf, pDict); firstOp = gFalse; } if (openPath) { charBuf->append((char)9); openPath = gFalse; } if (nOps != 1) { } cvtNum(ops[0].num, ops[0].isFP, charBuf); charBuf->append((char)4); nOps = 0; break; case 0x0005: // rlineto if (nOps < 2 || nOps % 2 != 0) { } for (k = 0; k < nOps; k += 2) { cvtNum(ops[k].num, ops[k].isFP, charBuf); cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf); charBuf->append((char)5); } nOps = 0; openPath = gTrue; break; case 0x0006: // hlineto if (nOps < 1) { } for (k = 0; k < nOps; ++k) { cvtNum(ops[k].num, ops[k].isFP, charBuf); charBuf->append((char)((k & 1) ? 7 : 6)); } nOps = 0; openPath = gTrue; break; case 0x0007: // vlineto if (nOps < 1) { } for (k = 0; k < nOps; ++k) { cvtNum(ops[k].num, ops[k].isFP, charBuf); charBuf->append((char)((k & 1) ? 6 : 7)); } nOps = 0; openPath = gTrue; break; case 0x0008: // rrcurveto if (nOps < 6 || nOps % 6 != 0) { } for (k = 0; k < nOps; k += 6) { cvtNum(ops[k].num, ops[k].isFP, charBuf); cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf); cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf); cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf); cvtNum(ops[k+4].num, ops[k+4].isFP, charBuf); cvtNum(ops[k+5].num, ops[k+5].isFP, charBuf); charBuf->append((char)8); } nOps = 0; openPath = gTrue; break; case 0x000a: // callsubr if (nOps >= 1) { subrBias = (subrIdx->len < 1240) ? 107 : (subrIdx->len < 33900) ? 1131 : 32768; k = subrBias + (int)ops[nOps - 1].num; --nOps; ok = gTrue; getIndexVal(subrIdx, k, &val, &ok); if (ok) { cvtGlyph(val.pos, val.len, charBuf, subrIdx, pDict, gFalse); } } else { } break; case 0x000b: // return break; case 0x000e: // endchar / seac if (firstOp) { cvtGlyphWidth(nOps == 1 || nOps == 5, charBuf, pDict); firstOp = gFalse; } if (openPath) { charBuf->append((char)9); openPath = gFalse; } if (nOps == 4) { cvtNum(0, gFalse, charBuf); cvtNum(ops[0].num, ops[0].isFP, charBuf); cvtNum(ops[1].num, ops[1].isFP, charBuf); cvtNum(ops[2].num, ops[2].isFP, charBuf); cvtNum(ops[3].num, ops[3].isFP, charBuf); charBuf->append((char)12)->append((char)6); } else if (nOps == 0) { charBuf->append((char)14); } else { } nOps = 0; break; case 0x000f: // (obsolete) if (firstOp) { cvtGlyphWidth(nOps > 0, charBuf, pDict); firstOp = gFalse; } nOps = 0; break; case 0x0010: // blend nOps = 0; break; case 0x0012: // hstemhm if (firstOp) { cvtGlyphWidth(nOps & 1, charBuf, pDict); firstOp = gFalse; } if (nOps & 1) { } nHints += nOps / 2; nOps = 0; break; case 0x0013: // hintmask if (firstOp) { cvtGlyphWidth(nOps & 1, charBuf, pDict); firstOp = gFalse; } if (nOps > 0) { if (nOps & 1) { } nHints += nOps / 2; } pos += (nHints + 7) >> 3; nOps = 0; break; case 0x0014: // cntrmask if (firstOp) { cvtGlyphWidth(nOps & 1, charBuf, pDict); firstOp = gFalse; } if (nOps > 0) { if (nOps & 1) { } nHints += nOps / 2; } pos += (nHints + 7) >> 3; nOps = 0; break; case 0x0015: // rmoveto if (firstOp) { cvtGlyphWidth(nOps == 3, charBuf, pDict); firstOp = gFalse; } if (openPath) { charBuf->append((char)9); openPath = gFalse; } if (nOps != 2) { } cvtNum(ops[0].num, ops[0].isFP, charBuf); cvtNum(ops[1].num, ops[1].isFP, charBuf); charBuf->append((char)21); nOps = 0; break; case 0x0016: // hmoveto if (firstOp) { cvtGlyphWidth(nOps == 2, charBuf, pDict); firstOp = gFalse; } if (openPath) { charBuf->append((char)9); openPath = gFalse; } if (nOps != 1) { } cvtNum(ops[0].num, ops[0].isFP, charBuf); charBuf->append((char)22); nOps = 0; break; case 0x0017: // vstemhm if (firstOp) { cvtGlyphWidth(nOps & 1, charBuf, pDict); firstOp = gFalse; } if (nOps & 1) { } nHints += nOps / 2; nOps = 0; break; case 0x0018: // rcurveline if (nOps < 8 || (nOps - 2) % 6 != 0) { } for (k = 0; k < nOps - 2; k += 6) { cvtNum(ops[k].num, ops[k].isFP, charBuf); cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf); cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf); cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf); cvtNum(ops[k+4].num, ops[k+4].isFP, charBuf); cvtNum(ops[k+5].num, ops[k+5].isFP, charBuf); charBuf->append((char)8); } cvtNum(ops[k].num, ops[k].isFP, charBuf); cvtNum(ops[k+1].num, ops[k].isFP, charBuf); charBuf->append((char)5); nOps = 0; openPath = gTrue; break; case 0x0019: // rlinecurve if (nOps < 8 || (nOps - 6) % 2 != 0) { } for (k = 0; k < nOps - 6; k += 2) { cvtNum(ops[k].num, ops[k].isFP, charBuf); cvtNum(ops[k+1].num, ops[k].isFP, charBuf); charBuf->append((char)5); } cvtNum(ops[k].num, ops[k].isFP, charBuf); cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf); cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf); cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf); cvtNum(ops[k+4].num, ops[k+4].isFP, charBuf); cvtNum(ops[k+5].num, ops[k+5].isFP, charBuf); charBuf->append((char)8); nOps = 0; openPath = gTrue; break; case 0x001a: // vvcurveto if (nOps < 4 || !(nOps % 4 == 0 || (nOps-1) % 4 == 0)) { } if (nOps % 2 == 1) { cvtNum(ops[0].num, ops[0].isFP, charBuf); cvtNum(ops[1].num, ops[1].isFP, charBuf); cvtNum(ops[2].num, ops[2].isFP, charBuf); cvtNum(ops[3].num, ops[3].isFP, charBuf); cvtNum(0, gFalse, charBuf); cvtNum(ops[4].num, ops[4].isFP, charBuf); charBuf->append((char)8); k = 5; } else { k = 0; } for (; k < nOps; k += 4) { cvtNum(0, gFalse, charBuf); cvtNum(ops[k].num, ops[k].isFP, charBuf); cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf); cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf); cvtNum(0, gFalse, charBuf); cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf); charBuf->append((char)8); } nOps = 0; openPath = gTrue; break; case 0x001b: // hhcurveto if (nOps < 4 || !(nOps % 4 == 0 || (nOps-1) % 4 == 0)) { } if (nOps % 2 == 1) { cvtNum(ops[1].num, ops[1].isFP, charBuf); cvtNum(ops[0].num, ops[0].isFP, charBuf); cvtNum(ops[2].num, ops[2].isFP, charBuf); cvtNum(ops[3].num, ops[3].isFP, charBuf); cvtNum(ops[4].num, ops[4].isFP, charBuf); cvtNum(0, gFalse, charBuf); charBuf->append((char)8); k = 5; } else { k = 0; } for (; k < nOps; k += 4) { cvtNum(ops[k].num, ops[k].isFP, charBuf); cvtNum(0, gFalse, charBuf); cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf); cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf); cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf); cvtNum(0, gFalse, charBuf); charBuf->append((char)8); } nOps = 0; openPath = gTrue; break; case 0x001d: // callgsubr if (nOps >= 1) { k = gsubrBias + (int)ops[nOps - 1].num; --nOps; ok = gTrue; getIndexVal(&gsubrIdx, k, &val, &ok); if (ok) { cvtGlyph(val.pos, val.len, charBuf, subrIdx, pDict, gFalse); } } else { } break; case 0x001e: // vhcurveto if (nOps < 4 || !(nOps % 4 == 0 || (nOps-1) % 4 == 0)) { } for (k = 0; k < nOps && k != nOps-5; k += 4) { if (k % 8 == 0) { cvtNum(ops[k].num, ops[k].isFP, charBuf); cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf); cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf); cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf); charBuf->append((char)30); } else { cvtNum(ops[k].num, ops[k].isFP, charBuf); cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf); cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf); cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf); charBuf->append((char)31); } } if (k == nOps-5) { if (k % 8 == 0) { cvtNum(0, gFalse, charBuf); cvtNum(ops[k].num, ops[k].isFP, charBuf); cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf); cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf); cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf); cvtNum(ops[k+4].num, ops[k+4].isFP, charBuf); } else { cvtNum(ops[k].num, ops[k].isFP, charBuf); cvtNum(0, gFalse, charBuf); cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf); cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf); cvtNum(ops[k+4].num, ops[k+4].isFP, charBuf); cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf); } charBuf->append((char)8); } nOps = 0; openPath = gTrue; break; case 0x001f: // hvcurveto if (nOps < 4 || !(nOps % 4 == 0 || (nOps-1) % 4 == 0)) { } for (k = 0; k < nOps && k != nOps-5; k += 4) { if (k % 8 == 0) { cvtNum(ops[k].num, ops[k].isFP, charBuf); cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf); cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf); cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf); charBuf->append((char)31); } else { cvtNum(ops[k].num, ops[k].isFP, charBuf); cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf); cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf); cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf); charBuf->append((char)30); } } if (k == nOps-5) { if (k % 8 == 0) { cvtNum(ops[k].num, ops[k].isFP, charBuf); cvtNum(0, gFalse, charBuf); cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf); cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf); cvtNum(ops[k+4].num, ops[k+4].isFP, charBuf); cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf); } else { cvtNum(0, gFalse, charBuf); cvtNum(ops[k].num, ops[k].isFP, charBuf); cvtNum(ops[k+1].num, ops[k+1].isFP, charBuf); cvtNum(ops[k+2].num, ops[k+2].isFP, charBuf); cvtNum(ops[k+3].num, ops[k+3].isFP, charBuf); cvtNum(ops[k+4].num, ops[k+4].isFP, charBuf); } charBuf->append((char)8); } nOps = 0; openPath = gTrue; break; case 0x0c00: // dotsection (should be Type 1 only?) nOps = 0; break; case 0x0c03: // and case 0x0c04: // or case 0x0c05: // not case 0x0c08: // store case 0x0c09: // abs case 0x0c0a: // add case 0x0c0b: // sub case 0x0c0c: // div case 0x0c0d: // load case 0x0c0e: // neg case 0x0c0f: // eq case 0x0c12: // drop case 0x0c14: // put case 0x0c15: // get case 0x0c16: // ifelse case 0x0c17: // random case 0x0c18: // mul case 0x0c1a: // sqrt case 0x0c1b: // dup case 0x0c1c: // exch case 0x0c1d: // index case 0x0c1e: // roll nOps = 0; break; case 0x0c22: // hflex if (nOps != 7) { } cvtNum(ops[0].num, ops[0].isFP, charBuf); cvtNum(0, gFalse, charBuf); cvtNum(ops[1].num, ops[1].isFP, charBuf); cvtNum(ops[2].num, ops[2].isFP, charBuf); cvtNum(ops[3].num, ops[3].isFP, charBuf); cvtNum(0, gFalse, charBuf); charBuf->append((char)8); cvtNum(ops[4].num, ops[4].isFP, charBuf); cvtNum(0, gFalse, charBuf); cvtNum(ops[5].num, ops[5].isFP, charBuf); cvtNum(-ops[2].num, ops[2].isFP, charBuf); cvtNum(ops[6].num, ops[6].isFP, charBuf); cvtNum(0, gFalse, charBuf); charBuf->append((char)8); nOps = 0; openPath = gTrue; break; case 0x0c23: // flex if (nOps != 13) { } cvtNum(ops[0].num, ops[0].isFP, charBuf); cvtNum(ops[1].num, ops[1].isFP, charBuf); cvtNum(ops[2].num, ops[2].isFP, charBuf); cvtNum(ops[3].num, ops[3].isFP, charBuf); cvtNum(ops[4].num, ops[4].isFP, charBuf); cvtNum(ops[5].num, ops[5].isFP, charBuf); charBuf->append((char)8); cvtNum(ops[6].num, ops[6].isFP, charBuf); cvtNum(ops[7].num, ops[7].isFP, charBuf); cvtNum(ops[8].num, ops[8].isFP, charBuf); cvtNum(ops[9].num, ops[9].isFP, charBuf); cvtNum(ops[10].num, ops[10].isFP, charBuf); cvtNum(ops[11].num, ops[11].isFP, charBuf); charBuf->append((char)8); nOps = 0; openPath = gTrue; break; case 0x0c24: // hflex1 if (nOps != 9) { } cvtNum(ops[0].num, ops[0].isFP, charBuf); cvtNum(ops[1].num, ops[1].isFP, charBuf); cvtNum(ops[2].num, ops[2].isFP, charBuf); cvtNum(ops[3].num, ops[3].isFP, charBuf); cvtNum(ops[4].num, ops[4].isFP, charBuf); cvtNum(0, gFalse, charBuf); charBuf->append((char)8); cvtNum(ops[5].num, ops[5].isFP, charBuf); cvtNum(0, gFalse, charBuf); cvtNum(ops[6].num, ops[6].isFP, charBuf); cvtNum(ops[7].num, ops[7].isFP, charBuf); cvtNum(ops[8].num, ops[8].isFP, charBuf); cvtNum(-(ops[1].num + ops[3].num + ops[7].num), ops[1].isFP | ops[3].isFP | ops[7].isFP, charBuf); charBuf->append((char)8); nOps = 0; openPath = gTrue; break; case 0x0c25: // flex1 if (nOps != 11) { } cvtNum(ops[0].num, ops[0].isFP, charBuf); cvtNum(ops[1].num, ops[1].isFP, charBuf); cvtNum(ops[2].num, ops[2].isFP, charBuf); cvtNum(ops[3].num, ops[3].isFP, charBuf); cvtNum(ops[4].num, ops[4].isFP, charBuf); cvtNum(ops[5].num, ops[5].isFP, charBuf); charBuf->append((char)8); cvtNum(ops[6].num, ops[6].isFP, charBuf); cvtNum(ops[7].num, ops[7].isFP, charBuf); cvtNum(ops[8].num, ops[8].isFP, charBuf); cvtNum(ops[9].num, ops[9].isFP, charBuf); dx = ops[0].num + ops[2].num + ops[4].num + ops[6].num + ops[8].num; dy = ops[1].num + ops[3].num + ops[5].num + ops[7].num + ops[9].num; if (fabs(dx) > fabs(dy)) { cvtNum(ops[10].num, ops[10].isFP, charBuf); cvtNum(-dy, ops[1].isFP | ops[3].isFP | ops[5].isFP | ops[7].isFP | ops[9].isFP, charBuf); } else { cvtNum(-dx, ops[0].isFP | ops[2].isFP | ops[4].isFP | ops[6].isFP | ops[8].isFP, charBuf); cvtNum(ops[10].num, ops[10].isFP, charBuf); } charBuf->append((char)8); nOps = 0; openPath = gTrue; break; default: nOps = 0; break; } } } if (top) { r2 = 4330; for (i = start; i < charBuf->getLength(); ++i) { byte = charBuf->getChar(i) ^ (r2 >> 8); charBuf->setChar(i, byte); r2 = (byte + r2) * 52845 + 22719; } } }
CWE-125
2,205
12,580
113411388115967369223657260141419225263
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
void FoFiType1C::cvtNum(double x, GBool isFP, GooString *charBuf) { Guchar buf[12]; int y, n; n = 0; if (isFP) { if (x >= -32768 && x < 32768) { y = (int)(x * 256.0); buf[0] = 255; buf[1] = (Guchar)(y >> 24); buf[2] = (Guchar)(y >> 16); buf[3] = (Guchar)(y >> 8); buf[4] = (Guchar)y; buf[5] = 255; buf[6] = 0; buf[7] = 0; buf[8] = 1; buf[9] = 0; buf[10] = 12; buf[11] = 12; n = 12; } else { } } else { y = (int)x; if (y >= -107 && y <= 107) { buf[0] = (Guchar)(y + 139); n = 1; } else if (y > 107 && y <= 1131) { y -= 108; buf[0] = (Guchar)((y >> 8) + 247); buf[1] = (Guchar)(y & 0xff); n = 2; } else if (y < -107 && y >= -1131) { y = -y - 108; buf[0] = (Guchar)((y >> 8) + 251); buf[1] = (Guchar)(y & 0xff); n = 2; } else { buf[0] = 255; buf[1] = (Guchar)(y >> 24); buf[2] = (Guchar)(y >> 16); buf[3] = (Guchar)(y >> 8); buf[4] = (Guchar)y; n = 5; } } charBuf->append((char *)buf, n); }
CWE-125
2,206
12,581
7610209460544787977187283330802161537
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
void FoFiType1C::eexecWrite(Type1CEexecBuf *eb, const char *s) { Guchar *p; Guchar x; for (p = (Guchar *)s; *p; ++p) { x = *p ^ (eb->r1 >> 8); eb->r1 = (x + eb->r1) * 52845 + 22719; if (eb->ascii) { (*eb->outputFunc)(eb->outputStream, &hexChars[x >> 4], 1); (*eb->outputFunc)(eb->outputStream, &hexChars[x & 0x0f], 1); eb->line += 2; if (eb->line == 64) { (*eb->outputFunc)(eb->outputStream, "\n", 1); eb->line = 0; } } else { (*eb->outputFunc)(eb->outputStream, (char *)&x, 1); } } }
CWE-125
2,208
12,582
149382853591758967487134270295165889818
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
void FoFiType1C::eexecWriteCharstring(Type1CEexecBuf *eb, Guchar *s, int n) { Guchar x; int i; for (i = 0; i < n; ++i) { x = s[i] ^ (eb->r1 >> 8); eb->r1 = (x + eb->r1) * 52845 + 22719; if (eb->ascii) { (*eb->outputFunc)(eb->outputStream, &hexChars[x >> 4], 1); (*eb->outputFunc)(eb->outputStream, &hexChars[x & 0x0f], 1); eb->line += 2; if (eb->line == 64) { (*eb->outputFunc)(eb->outputStream, "\n", 1); eb->line = 0; } } else { (*eb->outputFunc)(eb->outputStream, (char *)&x, 1); } } }
CWE-125
2,209
12,583
73552302461561655663308959871596732665
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
int *FoFiType1C::getCIDToGIDMap(int *nCIDs) { int *map; int n, i; if (topDict.firstOp != 0x0c1e) { *nCIDs = 0; return NULL; } n = 0; for (i = 0; i < nGlyphs && i < charsetLength; ++i) { if (charset[i] > n) { n = charset[i]; } } ++n; map = (int *)gmallocn(n, sizeof(int)); memset(map, 0, n * sizeof(int)); for (i = 0; i < nGlyphs; ++i) { map[charset[i]] = i; } *nCIDs = n; return map; }
CWE-125
2,210
12,584
300988775507354620721081684634307701290
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
int FoFiType1C::getDeltaIntArray(int *arr, int maxLen) { int x; int n, i; if ((n = nOps) > maxLen) { n = maxLen; } x = 0; for (i = 0; i < n; ++i) { x += (int)ops[i].num; arr[i] = x; } return n; }
CWE-125
2,212
12,585
337870466405912352086447527088724456733
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
char **FoFiType1C::getEncoding() { return encoding; }
CWE-125
2,213
12,586
269867170584341775487570480879209095351
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
void FoFiType1C::getFontMatrix(double *mat) { int i; if (topDict.firstOp == 0x0c1e && privateDicts[0].hasFontMatrix) { if (topDict.hasFontMatrix) { mat[0] = topDict.fontMatrix[0] * privateDicts[0].fontMatrix[0] + topDict.fontMatrix[1] * privateDicts[0].fontMatrix[2]; mat[1] = topDict.fontMatrix[0] * privateDicts[0].fontMatrix[1] + topDict.fontMatrix[1] * privateDicts[0].fontMatrix[3]; mat[2] = topDict.fontMatrix[2] * privateDicts[0].fontMatrix[0] + topDict.fontMatrix[3] * privateDicts[0].fontMatrix[2]; mat[3] = topDict.fontMatrix[2] * privateDicts[0].fontMatrix[1] + topDict.fontMatrix[3] * privateDicts[0].fontMatrix[3]; mat[4] = topDict.fontMatrix[4] * privateDicts[0].fontMatrix[0] + topDict.fontMatrix[5] * privateDicts[0].fontMatrix[2]; mat[5] = topDict.fontMatrix[4] * privateDicts[0].fontMatrix[1] + topDict.fontMatrix[5] * privateDicts[0].fontMatrix[3]; } else { for (i = 0; i < 6; ++i) { mat[i] = privateDicts[0].fontMatrix[i]; } } } else { for (i = 0; i < 6; ++i) { mat[i] = topDict.fontMatrix[i]; } } }
CWE-125
2,214
12,587
273950030922165452090023102900492280629
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
GooString *FoFiType1C::getGlyphName(int gid) { char buf[256]; GBool ok; ok = gTrue; if (gid < 0 || gid >= charsetLength) return NULL; getString(charset[gid], buf, &ok); if (!ok) { return NULL; } return new GooString(buf); }
CWE-125
2,215
12,588
243259455817763896673688759913229459528
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
void FoFiType1C::getIndex(int pos, Type1CIndex *idx, GBool *ok) { idx->pos = pos; idx->len = getU16BE(pos, ok); if (idx->len == 0) { idx->offSize = 0; idx->startPos = idx->endPos = pos + 2; } else { idx->offSize = getU8(pos + 2, ok); if (idx->offSize < 1 || idx->offSize > 4) { *ok = gFalse; } idx->startPos = pos + 3 + (idx->len + 1) * idx->offSize - 1; if (idx->startPos < 0 || idx->startPos >= len) { *ok = gFalse; } idx->endPos = idx->startPos + getUVarBE(pos + 3 + idx->len * idx->offSize, idx->offSize, ok); if (idx->endPos < idx->startPos || idx->endPos > len) { *ok = gFalse; } } }
CWE-125
2,216
12,589
107461941489488174784647990425256077344
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
void FoFiType1C::getIndexVal(Type1CIndex *idx, int i, Type1CIndexVal *val, GBool *ok) { int pos0, pos1; if (i < 0 || i >= idx->len) { *ok = gFalse; return; } pos0 = idx->startPos + getUVarBE(idx->pos + 3 + i * idx->offSize, idx->offSize, ok); pos1 = idx->startPos + getUVarBE(idx->pos + 3 + (i + 1) * idx->offSize, idx->offSize, ok); if (pos0 < idx->startPos || pos0 > idx->endPos || pos1 <= idx->startPos || pos1 > idx->endPos || pos1 < pos0) { *ok = gFalse; } val->pos = pos0; val->len = pos1 - pos0; }
CWE-125
2,217
12,590
218758403661259419425981709008905907209
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
char *FoFiType1C::getName() { return name ? name->getCString() : (char *)NULL; }
CWE-125
2,218
12,591
269534378516702565349171769796307096854
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
int FoFiType1C::getOp(int pos, GBool charstring, GBool *ok) { static char nybChars[16] = "0123456789.ee -"; Type1COp op; char buf[65]; int b0, b1, nyb0, nyb1, x, i; b0 = getU8(pos++, ok); op.isNum = gTrue; op.isFP = gFalse; if (b0 == 28) { x = getU8(pos++, ok); x = (x << 8) | getU8(pos++, ok); if (x & 0x8000) { x |= ~0xffff; } op.num = x; } else if (!charstring && b0 == 29) { x = getU8(pos++, ok); x = (x << 8) | getU8(pos++, ok); x = (x << 8) | getU8(pos++, ok); x = (x << 8) | getU8(pos++, ok); if (x & 0x80000000) { x |= ~0xffffffff; } op.num = x; } else if (!charstring && b0 == 30) { i = 0; do { b1 = getU8(pos++, ok); nyb0 = b1 >> 4; nyb1 = b1 & 0x0f; if (nyb0 == 0xf) { break; } buf[i++] = nybChars[nyb0]; if (i == 64) { break; } if (nyb0 == 0xc) { buf[i++] = '-'; } if (i == 64) { break; } if (nyb1 == 0xf) { break; } buf[i++] = nybChars[nyb1]; if (i == 64) { break; } if (nyb1 == 0xc) { buf[i++] = '-'; } } while (i < 64); buf[i] = '\0'; op.num = gatof(buf); op.isFP = gTrue; } else if (b0 >= 32 && b0 <= 246) { op.num = b0 - 139; } else if (b0 >= 247 && b0 <= 250) { op.num = ((b0 - 247) << 8) + getU8(pos++, ok) + 108; } else if (b0 >= 251 && b0 <= 254) { op.num = -((b0 - 251) << 8) - getU8(pos++, ok) - 108; } else if (charstring && b0 == 255) { x = getU8(pos++, ok); x = (x << 8) | getU8(pos++, ok); x = (x << 8) | getU8(pos++, ok); x = (x << 8) | getU8(pos++, ok); if (x & 0x80000000) { x |= ~0xffffffff; } op.num = (double)x / 65536.0; op.isFP = gTrue; } else if (b0 == 12) { op.isNum = gFalse; op.op = 0x0c00 + getU8(pos++, ok); } else { op.isNum = gFalse; op.op = b0; } if (nOps < 49) { ops[nOps++] = op; } return pos; }
CWE-125
2,219
12,592
269051169461771555312096748878669495361
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
char *FoFiType1C::getString(int sid, char *buf, GBool *ok) { Type1CIndexVal val; int n; if (sid < 0) { buf[0] = '\0'; } else if (sid < 391) { strcpy(buf, fofiType1CStdStrings[sid]); } else { sid -= 391; getIndexVal(&stringIdx, sid, &val, ok); if (*ok) { if ((n = val.len) > 255) { n = 255; } strncpy(buf, (char *)&file[val.pos], n); buf[n] = '\0'; } else { buf[0] = '\0'; } } return buf; }
CWE-125
2,220
12,593
328912220860697771454098526546485843401
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
FoFiType1C *FoFiType1C::load(char *fileName) { FoFiType1C *ff; char *fileA; int lenA; if (!(fileA = FoFiBase::readFile(fileName, &lenA))) { return NULL; } ff = new FoFiType1C(fileA, lenA, gTrue); if (!ff->parse()) { delete ff; return NULL; } return ff; }
CWE-125
2,221
12,594
35354844494090129332769551909828084592
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
GBool FoFiType1C::parse() { Type1CIndex fdIdx; Type1CIndexVal val; int i; parsedOk = gTrue; if (len > 0 && file[0] != '\x01') { ++file; --len; } getIndex(getU8(2, &parsedOk), &nameIdx, &parsedOk); getIndex(nameIdx.endPos, &topDictIdx, &parsedOk); getIndex(topDictIdx.endPos, &stringIdx, &parsedOk); getIndex(stringIdx.endPos, &gsubrIdx, &parsedOk); if (!parsedOk) { return gFalse; } gsubrBias = (gsubrIdx.len < 1240) ? 107 : (gsubrIdx.len < 33900) ? 1131 : 32768; getIndexVal(&nameIdx, 0, &val, &parsedOk); if (!parsedOk) { return gFalse; } name = new GooString((char *)&file[val.pos], val.len); readTopDict(); if (topDict.firstOp == 0x0c1e) { if (topDict.fdArrayOffset == 0) { nFDs = 1; privateDicts = (Type1CPrivateDict *)gmalloc(sizeof(Type1CPrivateDict)); readPrivateDict(0, 0, &privateDicts[0]); } else { getIndex(topDict.fdArrayOffset, &fdIdx, &parsedOk); if (!parsedOk) { return gFalse; } nFDs = fdIdx.len; privateDicts = (Type1CPrivateDict *) gmallocn(nFDs, sizeof(Type1CPrivateDict)); for (i = 0; i < nFDs; ++i) { getIndexVal(&fdIdx, i, &val, &parsedOk); if (!parsedOk) { return gFalse; } readFD(val.pos, val.len, &privateDicts[i]); } } } else { nFDs = 1; privateDicts = (Type1CPrivateDict *)gmalloc(sizeof(Type1CPrivateDict)); readPrivateDict(topDict.privateOffset, topDict.privateSize, &privateDicts[0]); } if (!parsedOk) { return gFalse; } if (topDict.charStringsOffset <= 0) { parsedOk = gFalse; return gFalse; } getIndex(topDict.charStringsOffset, &charStringsIdx, &parsedOk); if (!parsedOk) { return gFalse; } nGlyphs = charStringsIdx.len; if (topDict.firstOp == 0x0c1e) { readFDSelect(); if (!parsedOk) { return gFalse; } } if (!readCharset()) { parsedOk = gFalse; return gFalse; } if (topDict.firstOp != 0x0c14 && topDict.firstOp != 0x0c1e) { buildEncoding(); if (!parsedOk) { return gFalse; } } return parsedOk; }
CWE-125
2,223
12,595
110777194644308238206561125340373486205
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
GBool FoFiType1C::readCharset() { int charsetFormat, c, pos; int nLeft, i, j; if (topDict.charsetOffset == 0) { charset = fofiType1CISOAdobeCharset; charsetLength = sizeof(fofiType1CISOAdobeCharset) / sizeof(Gushort); } else if (topDict.charsetOffset == 1) { charset = fofiType1CExpertCharset; charsetLength = sizeof(fofiType1CExpertCharset) / sizeof(Gushort); } else if (topDict.charsetOffset == 2) { charset = fofiType1CExpertSubsetCharset; charsetLength = sizeof(fofiType1CExpertSubsetCharset) / sizeof(Gushort); } else { charset = (Gushort *)gmallocn(nGlyphs, sizeof(Gushort)); charsetLength = nGlyphs; for (i = 0; i < nGlyphs; ++i) { charset[i] = 0; } pos = topDict.charsetOffset; charsetFormat = getU8(pos++, &parsedOk); if (charsetFormat == 0) { for (i = 1; i < nGlyphs; ++i) { charset[i] = (Gushort)getU16BE(pos, &parsedOk); pos += 2; if (!parsedOk) { break; } } } else if (charsetFormat == 1) { i = 1; while (i < nGlyphs) { c = getU16BE(pos, &parsedOk); pos += 2; nLeft = getU8(pos++, &parsedOk); if (!parsedOk) { break; } for (j = 0; j <= nLeft && i < nGlyphs; ++j) { charset[i++] = (Gushort)c++; } } } else if (charsetFormat == 2) { i = 1; while (i < nGlyphs) { c = getU16BE(pos, &parsedOk); pos += 2; nLeft = getU16BE(pos, &parsedOk); pos += 2; if (!parsedOk) { break; } for (j = 0; j <= nLeft && i < nGlyphs; ++j) { charset[i++] = (Gushort)c++; } } } if (!parsedOk) { gfree(charset); charset = NULL; charsetLength = 0; return gFalse; } } return gTrue; }
CWE-125
2,224
12,596
147739182346530970083643869883428960257
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
void FoFiType1C::readFD(int offset, int length, Type1CPrivateDict *pDict) { int pos, pSize, pOffset; double fontMatrix[6] = {0}; GBool hasFontMatrix; hasFontMatrix = gFalse; fontMatrix[0] = fontMatrix[1] = fontMatrix[2] = 0; // make gcc happy fontMatrix[3] = fontMatrix[4] = fontMatrix[5] = 0; pSize = pOffset = 0; pos = offset; nOps = 0; while (pos < offset + length) { pos = getOp(pos, gFalse, &parsedOk); if (!parsedOk) { return; } if (!ops[nOps - 1].isNum) { if (ops[nOps - 1].op == 0x0012) { if (nOps < 3) { parsedOk = gFalse; return; } pSize = (int)ops[0].num; pOffset = (int)ops[1].num; break; } else if (ops[nOps - 1].op == 0x0c07) { fontMatrix[0] = ops[0].num; fontMatrix[1] = ops[1].num; fontMatrix[2] = ops[2].num; fontMatrix[3] = ops[3].num; fontMatrix[4] = ops[4].num; fontMatrix[5] = ops[5].num; hasFontMatrix = gTrue; } nOps = 0; } } readPrivateDict(pOffset, pSize, pDict); if (hasFontMatrix) { pDict->fontMatrix[0] = fontMatrix[0]; pDict->fontMatrix[1] = fontMatrix[1]; pDict->fontMatrix[2] = fontMatrix[2]; pDict->fontMatrix[3] = fontMatrix[3]; pDict->fontMatrix[4] = fontMatrix[4]; pDict->fontMatrix[5] = fontMatrix[5]; pDict->hasFontMatrix = gTrue; } }
CWE-125
2,225
12,597
195538857858037116521954122392868288603
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
void FoFiType1C::readFDSelect() { int fdSelectFmt, pos, nRanges, gid0, gid1, fd, i, j; fdSelect = (Guchar *)gmalloc(nGlyphs); if (topDict.fdSelectOffset == 0) { for (i = 0; i < nGlyphs; ++i) { fdSelect[i] = 0; } } else { pos = topDict.fdSelectOffset; fdSelectFmt = getU8(pos++, &parsedOk); if (!parsedOk) { return; } if (fdSelectFmt == 0) { if (!checkRegion(pos, nGlyphs)) { parsedOk = gFalse; return; } memcpy(fdSelect, file + pos, nGlyphs); } else if (fdSelectFmt == 3) { nRanges = getU16BE(pos, &parsedOk); pos += 2; gid0 = getU16BE(pos, &parsedOk); pos += 2; for (i = 1; i <= nRanges; ++i) { fd = getU8(pos++, &parsedOk); gid1 = getU16BE(pos, &parsedOk); if (!parsedOk) { return; } pos += 2; if (gid0 > gid1 || gid1 > nGlyphs) { parsedOk = gFalse; return; } for (j = gid0; j < gid1; ++j) { fdSelect[j] = fd; } gid0 = gid1; } } else { for (i = 0; i < nGlyphs; ++i) { fdSelect[i] = 0; } } } }
CWE-125
2,226
12,598
290535625021604982742726445189803960963
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
void FoFiType1C::readPrivateDict(int offset, int length, Type1CPrivateDict *pDict) { int pos; pDict->hasFontMatrix = gFalse; pDict->nBlueValues = 0; pDict->nOtherBlues = 0; pDict->nFamilyBlues = 0; pDict->nFamilyOtherBlues = 0; pDict->blueScale = 0.039625; pDict->blueShift = 7; pDict->blueFuzz = 1; pDict->hasStdHW = gFalse; pDict->hasStdVW = gFalse; pDict->nStemSnapH = 0; pDict->nStemSnapV = 0; pDict->hasForceBold = gFalse; pDict->forceBoldThreshold = 0; pDict->languageGroup = 0; pDict->expansionFactor = 0.06; pDict->initialRandomSeed = 0; pDict->subrsOffset = 0; pDict->defaultWidthX = 0; pDict->defaultWidthXFP = gFalse; pDict->nominalWidthX = 0; pDict->nominalWidthXFP = gFalse; if (offset == 0 || length == 0) { return; } pos = offset; nOps = 0; while (pos < offset + length) { pos = getOp(pos, gFalse, &parsedOk); if (!parsedOk) { break; } if (!ops[nOps - 1].isNum) { --nOps; // drop the operator switch (ops[nOps].op) { case 0x0006: pDict->nBlueValues = getDeltaIntArray(pDict->blueValues, type1CMaxBlueValues); break; case 0x0007: pDict->nOtherBlues = getDeltaIntArray(pDict->otherBlues, type1CMaxOtherBlues); break; case 0x0008: pDict->nFamilyBlues = getDeltaIntArray(pDict->familyBlues, type1CMaxBlueValues); break; case 0x0009: pDict->nFamilyOtherBlues = getDeltaIntArray(pDict->familyOtherBlues, type1CMaxOtherBlues); break; case 0x0c09: pDict->blueScale = ops[0].num; break; case 0x0c0a: pDict->blueShift = (int)ops[0].num; break; case 0x0c0b: pDict->blueFuzz = (int)ops[0].num; break; case 0x000a: pDict->stdHW = ops[0].num; pDict->hasStdHW = gTrue; break; case 0x000b: pDict->stdVW = ops[0].num; pDict->hasStdVW = gTrue; break; case 0x0c0c: pDict->nStemSnapH = getDeltaFPArray(pDict->stemSnapH, type1CMaxStemSnap); break; case 0x0c0d: pDict->nStemSnapV = getDeltaFPArray(pDict->stemSnapV, type1CMaxStemSnap); break; case 0x0c0e: pDict->forceBold = ops[0].num != 0; pDict->hasForceBold = gTrue; break; case 0x0c0f: pDict->forceBoldThreshold = ops[0].num; break; case 0x0c11: pDict->languageGroup = (int)ops[0].num; break; case 0x0c12: pDict->expansionFactor = ops[0].num; break; case 0x0c13: pDict->initialRandomSeed = (int)ops[0].num; break; case 0x0013: pDict->subrsOffset = offset + (int)ops[0].num; break; case 0x0014: pDict->defaultWidthX = ops[0].num; pDict->defaultWidthXFP = ops[0].isFP; break; case 0x0015: pDict->nominalWidthX = ops[0].num; pDict->nominalWidthXFP = ops[0].isFP; break; } nOps = 0; } } }
CWE-125
2,227
12,599
261810179316234669436805472708457075989
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
void FoFiType1C::readTopDict() { Type1CIndexVal topDictPtr; int pos; topDict.firstOp = -1; topDict.versionSID = 0; topDict.noticeSID = 0; topDict.copyrightSID = 0; topDict.fullNameSID = 0; topDict.familyNameSID = 0; topDict.weightSID = 0; topDict.isFixedPitch = 0; topDict.italicAngle = 0; topDict.underlinePosition = -100; topDict.underlineThickness = 50; topDict.paintType = 0; topDict.charstringType = 2; topDict.fontMatrix[0] = 0.001; topDict.fontMatrix[1] = 0; topDict.fontMatrix[2] = 0; topDict.fontMatrix[3] = 0.001; topDict.fontMatrix[4] = 0; topDict.fontMatrix[5] = 0; topDict.hasFontMatrix = gFalse; topDict.uniqueID = 0; topDict.fontBBox[0] = 0; topDict.fontBBox[1] = 0; topDict.fontBBox[2] = 0; topDict.fontBBox[3] = 0; topDict.strokeWidth = 0; topDict.charsetOffset = 0; topDict.encodingOffset = 0; topDict.charStringsOffset = 0; topDict.privateSize = 0; topDict.privateOffset = 0; topDict.registrySID = 0; topDict.orderingSID = 0; topDict.supplement = 0; topDict.fdArrayOffset = 0; topDict.fdSelectOffset = 0; getIndexVal(&topDictIdx, 0, &topDictPtr, &parsedOk); pos = topDictPtr.pos; nOps = 0; while (pos < topDictPtr.pos + topDictPtr.len) { pos = getOp(pos, gFalse, &parsedOk); if (!parsedOk) { break; } if (!ops[nOps - 1].isNum) { --nOps; // drop the operator if (topDict.firstOp < 0) { topDict.firstOp = ops[nOps].op; } switch (ops[nOps].op) { case 0x0000: topDict.versionSID = (int)ops[0].num; break; case 0x0001: topDict.noticeSID = (int)ops[0].num; break; case 0x0c00: topDict.copyrightSID = (int)ops[0].num; break; case 0x0002: topDict.fullNameSID = (int)ops[0].num; break; case 0x0003: topDict.familyNameSID = (int)ops[0].num; break; case 0x0004: topDict.weightSID = (int)ops[0].num; break; case 0x0c01: topDict.isFixedPitch = (int)ops[0].num; break; case 0x0c02: topDict.italicAngle = ops[0].num; break; case 0x0c03: topDict.underlinePosition = ops[0].num; break; case 0x0c04: topDict.underlineThickness = ops[0].num; break; case 0x0c05: topDict.paintType = (int)ops[0].num; break; case 0x0c06: topDict.charstringType = (int)ops[0].num; break; case 0x0c07: topDict.fontMatrix[0] = ops[0].num; topDict.fontMatrix[1] = ops[1].num; topDict.fontMatrix[2] = ops[2].num; topDict.fontMatrix[3] = ops[3].num; topDict.fontMatrix[4] = ops[4].num; topDict.fontMatrix[5] = ops[5].num; topDict.hasFontMatrix = gTrue; break; case 0x000d: topDict.uniqueID = (int)ops[0].num; break; case 0x0005: topDict.fontBBox[0] = ops[0].num; topDict.fontBBox[1] = ops[1].num; topDict.fontBBox[2] = ops[2].num; topDict.fontBBox[3] = ops[3].num; break; case 0x0c08: topDict.strokeWidth = ops[0].num; break; case 0x000f: topDict.charsetOffset = (int)ops[0].num; break; case 0x0010: topDict.encodingOffset = (int)ops[0].num; break; case 0x0011: topDict.charStringsOffset = (int)ops[0].num; break; case 0x0012: topDict.privateSize = (int)ops[0].num; topDict.privateOffset = (int)ops[1].num; break; case 0x0c1e: topDict.registrySID = (int)ops[0].num; topDict.orderingSID = (int)ops[1].num; topDict.supplement = (int)ops[2].num; break; case 0x0c24: topDict.fdArrayOffset = (int)ops[0].num; break; case 0x0c25: topDict.fdSelectOffset = (int)ops[0].num; break; } nOps = 0; } } }
CWE-125
2,228
12,600
140465452717788501244730177279626384190
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
void FoFiType1C::writePSString(char *s, FoFiOutputFunc outputFunc, void *outputStream) { char buf[80]; char *p; int i, c; i = 0; buf[i++] = '('; for (p = s; *p; ++p) { c = *p & 0xff; if (c == '(' || c == ')' || c == '\\') { buf[i++] = '\\'; buf[i++] = c; } else if (c < 0x20 || c >= 0x80) { buf[i++] = '\\'; buf[i++] = '0' + ((c >> 6) & 7); buf[i++] = '0' + ((c >> 3) & 7); buf[i++] = '0' + (c & 7); } else { buf[i++] = c; } if (i >= 64) { buf[i++] = '\\'; buf[i++] = '\n'; (*outputFunc)(outputStream, buf, i); i = 0; } } buf[i++] = ')'; (*outputFunc)(outputStream, buf, i); }
CWE-125
2,229
12,601
274333630754969180250421745162560135465
null
null
null
poppler
da63c35549e8852a410946ab016a3f25ac701bdf
0
FoFiType1C::~FoFiType1C() { int i; if (name) { delete name; } if (encoding && encoding != fofiType1StandardEncoding && encoding != fofiType1ExpertEncoding) { for (i = 0; i < 256; ++i) { gfree(encoding[i]); } gfree(encoding); } if (privateDicts) { gfree(privateDicts); } if (fdSelect) { gfree(fdSelect); } if (charset && charset != fofiType1CISOAdobeCharset && charset != fofiType1CExpertCharset && charset != fofiType1CExpertSubsetCharset) { gfree(charset); } }
CWE-125
2,230
12,602
79914171410358599153902211880981782185
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_by_id(int id) { Channel *c; if (id < 0 || (u_int)id >= channels_alloc) { logit("channel_by_id: %d: bad id", id); return NULL; } c = channels[id]; if (c == NULL) { logit("channel_by_id: %d: bad id: channel free", id); return NULL; } return c; }
CWE-264
2,237
12,603
101959152129956666703147306743688257032
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_cancel_cleanup(int id) { Channel *c = channel_by_id(id); if (c == NULL) { logit("channel_cancel_cleanup: %d: bad id", id); return; } c->detach_user = NULL; c->detach_close = 0; }
CWE-264
2,238
12,604
226143744237702877719506053581867214991
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_close_all(void) { u_int i; for (i = 0; i < channels_alloc; i++) if (channels[i] != NULL) channel_close_fds(channels[i]); }
CWE-264
2,239
12,605
330619020875761910663382875139586874674
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_close_fd(int *fdp) { int ret = 0, fd = *fdp; if (fd != -1) { ret = close(fd); *fdp = -1; if (fd == channel_max_fd) channel_max_fd = channel_find_maxfd(); } return ret; }
CWE-264
2,240
12,606
94611746523128027009013756652163650154
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_close_fds(Channel *c) { channel_close_fd(&c->sock); channel_close_fd(&c->rfd); channel_close_fd(&c->wfd); channel_close_fd(&c->efd); }
CWE-264
2,241
12,607
162503335223069327983062771981843606037
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_find_maxfd(void) { u_int i; int max = 0; Channel *c; for (i = 0; i < channels_alloc; i++) { c = channels[i]; if (c != NULL) { max = MAX(max, c->rfd); max = MAX(max, c->wfd); max = MAX(max, c->efd); } } return max; }
CWE-264
2,242
12,608
279004556027265658940682136969080435313
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_find_open(void) { u_int i; Channel *c; for (i = 0; i < channels_alloc; i++) { c = channels[i]; if (c == NULL || c->remote_id < 0) continue; switch (c->type) { case SSH_CHANNEL_CLOSED: case SSH_CHANNEL_DYNAMIC: case SSH_CHANNEL_X11_LISTENER: case SSH_CHANNEL_PORT_LISTENER: case SSH_CHANNEL_RPORT_LISTENER: case SSH_CHANNEL_MUX_LISTENER: case SSH_CHANNEL_MUX_CLIENT: case SSH_CHANNEL_OPENING: case SSH_CHANNEL_CONNECTING: case SSH_CHANNEL_ZOMBIE: case SSH_CHANNEL_ABANDONED: case SSH_CHANNEL_UNIX_LISTENER: case SSH_CHANNEL_RUNIX_LISTENER: continue; case SSH_CHANNEL_LARVAL: case SSH_CHANNEL_AUTH_SOCKET: case SSH_CHANNEL_OPEN: case SSH_CHANNEL_X11_OPEN: return i; case SSH_CHANNEL_INPUT_DRAINING: case SSH_CHANNEL_OUTPUT_DRAINING: if (!compat13) fatal("cannot happen: OUT_DRAIN"); return i; default: fatal("channel_find_open: bad channel type %d", c->type); /* NOTREACHED */ } } return -1; }
CWE-264
2,243
12,609
134488432704538231244841759912871754802
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_free(Channel *c) { char *s; u_int i, n; struct channel_confirm *cc; for (n = 0, i = 0; i < channels_alloc; i++) if (channels[i]) n++; debug("channel %d: free: %s, nchannels %u", c->self, c->remote_name ? c->remote_name : "???", n); s = channel_open_message(); debug3("channel %d: status: %s", c->self, s); free(s); if (c->sock != -1) shutdown(c->sock, SHUT_RDWR); channel_close_fds(c); buffer_free(&c->input); buffer_free(&c->output); buffer_free(&c->extended); free(c->remote_name); c->remote_name = NULL; free(c->path); c->path = NULL; free(c->listening_addr); c->listening_addr = NULL; while ((cc = TAILQ_FIRST(&c->status_confirms)) != NULL) { if (cc->abandon_cb != NULL) cc->abandon_cb(c, cc->ctx); TAILQ_REMOVE(&c->status_confirms, cc, entry); explicit_bzero(cc, sizeof(*cc)); free(cc); } if (c->filter_cleanup != NULL && c->filter_ctx != NULL) c->filter_cleanup(c->self, c->filter_ctx); channels[c->self] = NULL; free(c); }
CWE-264
2,244
12,610
296605497581080488409349416555261518081
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_free_all(void) { u_int i; for (i = 0; i < channels_alloc; i++) if (channels[i] != NULL) channel_free(channels[i]); }
CWE-264
2,245
12,611
121221254896838925968308752920087460772
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_lookup(int id) { Channel *c; if ((c = channel_by_id(id)) == NULL) return (NULL); switch (c->type) { case SSH_CHANNEL_X11_OPEN: case SSH_CHANNEL_LARVAL: case SSH_CHANNEL_CONNECTING: case SSH_CHANNEL_DYNAMIC: case SSH_CHANNEL_OPENING: case SSH_CHANNEL_OPEN: case SSH_CHANNEL_INPUT_DRAINING: case SSH_CHANNEL_OUTPUT_DRAINING: case SSH_CHANNEL_ABANDONED: return (c); } logit("Non-public channel %d, type %d.", id, c->type); return (NULL); }
CWE-264
2,246
12,612
28479340263004214202219155780874592758
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_open_message(void) { Buffer buffer; Channel *c; char buf[1024], *cp; u_int i; buffer_init(&buffer); snprintf(buf, sizeof buf, "The following connections are open:\r\n"); buffer_append(&buffer, buf, strlen(buf)); for (i = 0; i < channels_alloc; i++) { c = channels[i]; if (c == NULL) continue; switch (c->type) { case SSH_CHANNEL_X11_LISTENER: case SSH_CHANNEL_PORT_LISTENER: case SSH_CHANNEL_RPORT_LISTENER: case SSH_CHANNEL_CLOSED: case SSH_CHANNEL_AUTH_SOCKET: case SSH_CHANNEL_ZOMBIE: case SSH_CHANNEL_ABANDONED: case SSH_CHANNEL_MUX_CLIENT: case SSH_CHANNEL_MUX_LISTENER: case SSH_CHANNEL_UNIX_LISTENER: case SSH_CHANNEL_RUNIX_LISTENER: continue; case SSH_CHANNEL_LARVAL: case SSH_CHANNEL_OPENING: case SSH_CHANNEL_CONNECTING: case SSH_CHANNEL_DYNAMIC: case SSH_CHANNEL_OPEN: case SSH_CHANNEL_X11_OPEN: case SSH_CHANNEL_INPUT_DRAINING: case SSH_CHANNEL_OUTPUT_DRAINING: snprintf(buf, sizeof buf, " #%d %.300s (t%d r%d i%d/%d o%d/%d fd %d/%d cc %d)\r\n", c->self, c->remote_name, c->type, c->remote_id, c->istate, buffer_len(&c->input), c->ostate, buffer_len(&c->output), c->rfd, c->wfd, c->ctl_chan); buffer_append(&buffer, buf, strlen(buf)); continue; default: fatal("channel_open_message: bad channel type %d", c->type); /* NOTREACHED */ } } buffer_append(&buffer, "\0", 1); cp = xstrdup((char *)buffer_ptr(&buffer)); buffer_free(&buffer); return cp; }
CWE-264
2,247
12,613
237310304691336803752947761063160154129
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_pre_connecting(Channel *c, fd_set *readset, fd_set *writeset) { debug3("channel %d: waiting for connection", c->self); FD_SET(c->sock, writeset); }
CWE-264
2,248
12,614
66527700018417632172816709233748899982
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_pre_input_draining(Channel *c, fd_set *readset, fd_set *writeset) { if (buffer_len(&c->input) == 0) { packet_start(SSH_MSG_CHANNEL_CLOSE); packet_put_int(c->remote_id); packet_send(); c->type = SSH_CHANNEL_CLOSED; debug2("channel %d: closing after input drain.", c->self); } }
CWE-264
2,249
12,615
95400244150625861765005556448611903010
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_pre_listener(Channel *c, fd_set *readset, fd_set *writeset) { FD_SET(c->sock, readset); }
CWE-264
2,250
12,616
281915963052709106515994718350990572079
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_pre_open(Channel *c, fd_set *readset, fd_set *writeset) { u_int limit = compat20 ? c->remote_window : packet_get_maxsize(); if (c->istate == CHAN_INPUT_OPEN && limit > 0 && buffer_len(&c->input) < limit && buffer_check_alloc(&c->input, CHAN_RBUF)) FD_SET(c->rfd, readset); if (c->ostate == CHAN_OUTPUT_OPEN || c->ostate == CHAN_OUTPUT_WAIT_DRAIN) { if (buffer_len(&c->output) > 0) { FD_SET(c->wfd, writeset); } else if (c->ostate == CHAN_OUTPUT_WAIT_DRAIN) { if (CHANNEL_EFD_OUTPUT_ACTIVE(c)) debug2("channel %d: obuf_empty delayed efd %d/(%d)", c->self, c->efd, buffer_len(&c->extended)); else chan_obuf_empty(c); } } /** XXX check close conditions, too */ if (compat20 && c->efd != -1 && !(c->istate == CHAN_INPUT_CLOSED && c->ostate == CHAN_OUTPUT_CLOSED)) { if (c->extended_usage == CHAN_EXTENDED_WRITE && buffer_len(&c->extended) > 0) FD_SET(c->efd, writeset); else if (c->efd != -1 && !(c->flags & CHAN_EOF_SENT) && (c->extended_usage == CHAN_EXTENDED_READ || c->extended_usage == CHAN_EXTENDED_IGNORE) && buffer_len(&c->extended) < c->remote_window) FD_SET(c->efd, readset); } /* XXX: What about efd? races? */ }
CWE-264
2,251
12,617
323020791920411164358028991716136979385
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_pre_open_13(Channel *c, fd_set *readset, fd_set *writeset) { if (buffer_len(&c->input) < packet_get_maxsize()) FD_SET(c->sock, readset); if (buffer_len(&c->output) > 0) FD_SET(c->sock, writeset); }
CWE-264
2,252
12,618
99003324896257341888839079850795398433
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_pre_output_draining(Channel *c, fd_set *readset, fd_set *writeset) { if (buffer_len(&c->output) == 0) chan_mark_dead(c); else FD_SET(c->sock, writeset); }
CWE-264
2,253
12,619
3127162216993102379597795156494159824
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_register_cleanup(int id, channel_callback_fn *fn, int do_close) { Channel *c = channel_by_id(id); if (c == NULL) { logit("channel_register_cleanup: %d: bad id", id); return; } c->detach_user = fn; c->detach_close = do_close; }
CWE-264
2,254
12,620
258736056843352990932321384796622375720
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_register_fds(Channel *c, int rfd, int wfd, int efd, int extusage, int nonblock, int is_tty) { /* Update the maximum file descriptor value. */ channel_max_fd = MAX(channel_max_fd, rfd); channel_max_fd = MAX(channel_max_fd, wfd); channel_max_fd = MAX(channel_max_fd, efd); if (rfd != -1) fcntl(rfd, F_SETFD, FD_CLOEXEC); if (wfd != -1 && wfd != rfd) fcntl(wfd, F_SETFD, FD_CLOEXEC); if (efd != -1 && efd != rfd && efd != wfd) fcntl(efd, F_SETFD, FD_CLOEXEC); c->rfd = rfd; c->wfd = wfd; c->sock = (rfd == wfd) ? rfd : -1; c->efd = efd; c->extended_usage = extusage; if ((c->isatty = is_tty) != 0) debug2("channel %d: rfd %d isatty", c->self, c->rfd); #ifdef _AIX /* XXX: Later AIX versions can't push as much data to tty */ c->wfd_isatty = is_tty || isatty(c->wfd); #endif /* enable nonblocking mode */ if (nonblock) { if (rfd != -1) set_nonblock(rfd); if (wfd != -1) set_nonblock(wfd); if (efd != -1) set_nonblock(efd); } }
CWE-264
2,255
12,621
13862677787699060775186165326699661637
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_register_filter(int id, channel_infilter_fn *ifn, channel_outfilter_fn *ofn, channel_filter_cleanup_fn *cfn, void *ctx) { Channel *c = channel_lookup(id); if (c == NULL) { logit("channel_register_filter: %d: bad id", id); return; } c->input_filter = ifn; c->output_filter = ofn; c->filter_ctx = ctx; c->filter_cleanup = cfn; }
CWE-264
2,256
12,622
288256709499349136555341660936658738054
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_request_start(int id, char *service, int wantconfirm) { Channel *c = channel_lookup(id); if (c == NULL) { logit("channel_request_start: %d: unknown channel id", id); return; } debug2("channel %d: request %s confirm %d", id, service, wantconfirm); packet_start(SSH2_MSG_CHANNEL_REQUEST); packet_put_int(c->remote_id); packet_put_cstring(service); packet_put_char(wantconfirm); }
CWE-264
2,259
12,623
306834342012287666918475669575468669112
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_send_open(int id) { Channel *c = channel_lookup(id); if (c == NULL) { logit("channel_send_open: %d: bad id", id); return; } debug2("channel %d: send open", id); packet_start(SSH2_MSG_CHANNEL_OPEN); packet_put_cstring(c->ctype); packet_put_int(c->self); packet_put_int(c->local_window); packet_put_int(c->local_maxpacket); packet_send(); }
CWE-264
2,260
12,624
266424650272991826146234700878383547212
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_set_fds(int id, int rfd, int wfd, int efd, int extusage, int nonblock, int is_tty, u_int window_max) { Channel *c = channel_lookup(id); if (c == NULL || c->type != SSH_CHANNEL_LARVAL) fatal("channel_activate for non-larval channel %d.", id); channel_register_fds(c, rfd, wfd, efd, extusage, nonblock, is_tty); c->type = SSH_CHANNEL_OPEN; c->local_window = c->local_window_max = window_max; packet_start(SSH2_MSG_CHANNEL_WINDOW_ADJUST); packet_put_int(c->remote_id); packet_put_int(c->local_window); packet_send(); }
CWE-264
2,261
12,625
163042860905322519569728194646457094893
null
null
null
mindrot
1bf477d3cdf1a864646d59820878783d42357a1d
0
channel_stop_listening(void) { u_int i; Channel *c; for (i = 0; i < channels_alloc; i++) { c = channels[i]; if (c != NULL) { switch (c->type) { case SSH_CHANNEL_AUTH_SOCKET: case SSH_CHANNEL_PORT_LISTENER: case SSH_CHANNEL_RPORT_LISTENER: case SSH_CHANNEL_X11_LISTENER: case SSH_CHANNEL_UNIX_LISTENER: case SSH_CHANNEL_RUNIX_LISTENER: channel_close_fd(&c->sock); channel_free(c); break; } } } }
CWE-264
2,263
12,626
327713376389334648854550620194522955214
null
null
null